(C#) ASP.NET Web User Control (Code Behind) ตัวอย่างการเขียน Web User Control ในรูปแบบของ Code Behind ที่เขียนแยกระหว่าง .aspx และ .aspx.vb หรือ aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class MyWebPage1 : System.Web.UI.Page
{
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
}
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class MyUserControl1 : System.Web.UI.UserControl
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
}
Screenshot
ASP.NET & Visual Studio .Net 2003 - Web User Control