Welcome To My Blog

This blog contains posts that may benefit ordinary visitors or programmers (particularly .NET programmer).
To view posts related to particular subjects, click the link under Labels.

Tuesday, September 16, 2008

Using MasterPage Template In ASP.Net 2005 Application

Introduction

A Master Page in Visual Studio 2005 is just like a template. You can place banners, menus, images and etc on the master page. You can also include codes (functions) on the master page. You can include more than one master page in any asp.net 2005 web application.

Once you have the master page, you can generate the content page (aspx page) which is linked to the master page. This way, you can have several aspx pages (content pages) with a consistent look. In other words, all content pages generated using a master page, will have the same appearance as the master page. For example, if you have placed a banner at the top and navigation menu on the left side of the master page, all content pages will also have the banner at the top and menu on the left side.

How To Add Master Page To ASP.Net Project?
Adding a master page to an ASP.NET project is very easy. You just need to do the following steps:
  1. Right-click on the project name in the Solution Explorer window.
  2. Select Add New Item... from the pop up menu.
  3. Select Master Page from the Add New Item dialog box. If necessary, change the name and the language for the master page. Then click the Add button. You will see a master page is displayed either in the Source or Design view.
  4. Design you master page. For example, you can add an HTML table on the master page. After that, you can arrange the the ContentPlaceHolder control, images, buttons and other controls nicely within the HTML table. You may look at the image below for an example.

How To Add Content Page (aspx page) Using A Master Page?
To add a content page to your asp.net project using a particular master page is relatively easy. All you need to do are:
  1. Open the particular master page that you want to use to generate the master page.
  2. Right-click anywhere within the Design or Source view window and select Add Content Page from the pop up menu that appears.
  3. Notice the asp.net content control in the generated aspx page. This is where you place your content such as text, iframe, images and etc for your content page.
Remember that we use master page to generate a consistent aspx page. Though you cannot set a master page as the start page of your website, you still need to include it in your asp.net web site. This is because the page that is generated using the master page has a link to the master page.

Sunday, September 14, 2008

How To Define SQL Parameters In C# (VS2005)

Hi there...

This post is dedicated to programmers (beginners) who want to use SQL statements when coding in C#. Before I continue, let me ask you something. Do you know what a parameter in an SQL statement is?

A parameter is just like a placeholder or variable where you define the location for the actual value in the SQL statement. Since it works like a variable, the value can be changed anytime during the SQL execution. Examples are as follow:

SELECT * FROM Employees WHERE EmployeeID = @EmployeeID;

UPDATE Employees SET FirstName=@FirstName WHERE EmployeeID = @EmployeeID;

DELETE Employees WHERE EmployeeID = @EmployeeID;

INSERT INTO Employees (EmployeeID, FirstName, LastName) VALUES (@EmployeeID, @FirstName, @LastName);

In the above examples, @EmployeeID, @FirstName and @LastName are called parameters. A parameter represents a value that you need to set (or assigned) before you execute the particular SQL statement that contains it.

The question now is how are we going to do it in C#? Let's assume you want to use a SELECT statement in the SqlCommand object.

You got to follow the steps below:
  1. Define an SQL Connection object, example:
    SqlConnection conNorthwind = new SqlConnection("server=localhost;uid=sa;pwd=;database=northwind;");
  2. Define an SQL Command object, example:
    SqlCommand cmdEmployees = new SqlCommand("SELECT * FROM Employees WHERE EmployeeID = @EmployeeID", conNorthwind);
  3. Define a parameter and pass the value from a textbox to it. Then, add it to the SqlCommand parameters collection, example:
    SqlParameter paraEmployeeID = new SqlParameter("@EmployeeID", txtEmployeeID.Text);
    cmdEmployees.Parameters.Add(paraEmployeeID);
  4. Open the SqlConnection, example:
    conNorthwind.Open();
  5. Now you may pass the command object to an SqlDataReader or SqlDataAdapter.
    To pass it to an SqlDataReader, you may do the following:
    SqlDataReader drEmployees = cmdEmployees.ExecuteReader();
    To pass it to an SqlDataAdapter, do the following:
    SqlDataAdapter daEmployees = new SqlDataAdapter(cmdEmployees);
  6. If you pass the command object to an SqlDataReader using the ExecuteReader method, you can display the retrieved rows directly in a GridView (web control) using the following code:
    GridView1.DataSource = drEmployees;
    GridView1.DataBind();
  7. If you pass the command object to an SqlDataAdapter, you have to define a dataset also since a DataAdapter can only work with a DataSet. Assuming that you want to display the result in the same web control (GridView). You may write the following codes:
    Dataset dsNorthwind = new DataSet();
    //"Employees" is just a datatable name. It can be replaced with any name.
    daEmployees.Fill(dsNorthwind, "Employees");
    GridView1.DataSource = dsNorthwind.Tables["Employees"];
    GridView1.DataBind();
  8. Finally, close the connection as follows:
    conNorthwind.Close();
Notes: If you are using an SqlDataAdapter, it is not necessary to open and close the connection explicitly. This is because the SqlDataAdapter can open and close the connection implicitly.

Friday, September 12, 2008

Google Sudah Lancarkan Browser Sendiri

Rasanya ramai pengguna internet tahu apa itu Google -- sebuah syarikat internet yang menyediakan Enjin Carian secara percuma. Baru-baru ini Google telah melancarkan "internet browser"nya sendiri yang dikenali dengan nama Google Chrome.

Saya telah mencuba browser ini dan saya dapati ianya agak pantas berbanding browser-browser lain seperti Internet Explorer dan Firefox. Antaramuka (interface) untuk browser ini nampak ringkas dan mudah untuk digunakan. Walaupun masih di peringkat "beta version", browser ini dapat memaparkan sebarang laman tanpa masalah.

Untuk mengetahui lebih lanjut tentang browser ini, sila klik pautan (link) di bawah:
http://www.google.com/chrome
Untuk memuatturun (download) offline-installer untuk browser ini, sila klik pautan di bawah:
chrome_installer.exe

Thursday, September 11, 2008

Penyerahan Borang Cadangan Takaful Etiqa

Assalamualaikum...

Artikel ini ditujukan khas kepada wakil-wakil Etiqa Takaful. Untuk penyerahan borang cadangan takaful, anda perlu menyediakan sekurang-kurang 4 dokumen tersebut:
  1. Salinan kad pengenalan pelanggan takaful.
  2. Borang carian fakta pelanggan.
  3. Borang cadangan untuk menyertai pelan takaful.
  4. Ilustrasi pelan.
Jika pelan yang dicadangankan turut mengandungi pelan sampingan Penyakit Kritikal (Critical Illness), anda juga perlu menyertakan borang untuk Critical Illness.

Kesemua borang boleh didapati di kaunter Etiqa cawangan anda.

Untuk keterangan lanjut, sila bertanya dengan Agency Manager atau Group Agency Manager anda.

Thursday, July 3, 2008

Hikmah Berpuasa Di Bulan Rejab

Sama samalah kita ingat mengingati amalan amalan mulia yang penuh berkat ini……….


BULAN REJAB
Pada 4 Julai 2008 (Jumaat) kita memasuki bulan Rejab. Bulan Rejab adalah bulan Allah swt. Let's overview ada apa di sebalik bulan Rejab itu.

Diriwayatkan bahwa Rasulullah saw telah bersabda, "Ketahuilah bahwa bln Rejab itu adalah bulan ALLAH swt, maka:"
1. Barang siapa yang berpuasa 1 hari dalam bulan ini dengan ikhlas, maka pasti ia mendapat keredhaan yang besar dari ALLAH swt

2. Dan barang siapa berpuasa pada tanggal 27 Rejab 1429h/Isra Mi'raj (Rabu, 30 Julai 2008) akan mendapat pahala seperti 5 tahun berpuasa

3. Barang siapa yang berpuasa 2 hari di bulan Rejab akan mendapat kemuliaan di sisi ALLAH swt

4. Barang siapa yang berpuasa 3 hari yaitu pada tanggal 1, 2, dan 3 Rejab (4, 5, 6 Julai 2008) maka ALLAH swt akan memberikan pahala seperti 900 tahun berpuasa dan menyelamatkannya dari bahaya dunia dan seksa akhirat

5. Barang siapa berpuasa 5 hari dalam bulan ini, insyaallah permintaannya akan dimakbulkan Allah swt..InsyaAllah

6. Barang siapa berpuasa 7 hari dalam bulan ini, maka ditutupkan 7 pintu neraka Jahanam dan barang siapa berpuasa delapan hari maka akan dibukakan 8 pintu syurga

7. Barang siapa berpuasa 15 hari dalam bulan ini, maka ALLAH swt akan mengampuni dosa-dosanya yang telah lalu dan menggantikan kesemua kejahatannya dengan kebaikan, dan barang siapa yang menambah (hari-hari puasa) maka ALLAH swt akan menambahkan pahalanya."

Sabda Rasulullah saw lagi :"Pada malam Mi'raj, saya melihat sebuah sungai yang airnya lebih manis dari madu, lebih sejuk dari air batu dan lebih harum dari minyak wangi, lalu saya bertanya pada Jibril as "Wahai Jibril untuk siapakah sungai ini?"

Maka berkata Jibrilb as "Ya Muhammad sungai ini adalah untuk orang yang membaca selawat untuk engkau dibulan Rejab i ni."

Dalam sebuah riwayat Tsauban bercerita :"Ketika kami berjalan bersama-sama Rasulullah saw ke sebuah kubur, lalu Rasulullah saw berhenti dan beliau menangis dengan amat sedih, kemudian beliau berdoa kepada ALLAH swt. Lalu saya bertanya kepada beliau "Ya Rasulullah, mengapakah engkau menangis?" Lalu beliau bersabda "Wahai Tsauban, mereka itu sedang diseksa dalam kuburnya dan saya berdoa kepada ALLAH swt, lalu ALLAH swt meringankan atas mereka.."

Sabda beliau lagi "Wahai Tsauban, kalaulah sekiranya mereka ini mahu berpuasa satu hari dan beribadah satu malam saja di bulan Rejab nescaya mereka tidak akan disiksa di dalam kubur." Tsauban bertanya "Ya Rasulullah, apakah hanya berpuasa satu hari dan beribadah satu malam dalam bulan Rejab sudah dapat mengelakkan dari seksa kubur"

Sabda beliau "Wahai Tsauban, demi ALLAH Zat yang telah mengutus saya sebagai nabi, tiada seorang muslim lelaki dan perempuan yang berpuasa satu hari dan mengerjakan solat malam sekali dalam bulan Rejab dengan niat karena ALLAH swt, kecuali ALLAH swt mencatatkan baginya seperti berpuasa satu tahun dan mengerjakan solat malam satu tahun."


p:s Rebutlah 5 perkara sblm dtg 5 perkara – 1. Lapang sebelum sibuk, 2.. Senang sebelum susah, 3. Kaya sebelum miskin, 4. Sihat sebelum sakit dan 5. Hidup sebelum mati.

Catitan: Artikel di atas di ambil dari e-mail yang dihantar kepada saya. Tujuan saya letakkan di sini adalah untuk berkongsi ilmu dengan sesama insan, Muslim terutamanya.

Thursday, June 12, 2008

My First Blog

Hi, welcome to my first blog. I'm not really sure what to put here. I'm not really good in writing. Just don't have the ideas yet.

Anyway, let me introduce myself. I am Safuan bin Abdul Latif from Selangor, Malaysia. Currently working as a full-time ACCP (Aptech Certified Computer Professional) Trainer in Cosmopoint KL, Jalan Raja Laut, Kuala Lumpur.

My specialization is in Microsoft.Net. I have been training IT graduates for this program since 2005.