Sparko wrote:
OK, here is the WebForm1.aspx.cs file, the aspx file is simple HTML
with the <asp:Label /> control as suggested ....
namespace dotNETDev
{
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;
/// <summary>
/// Summary description for WebForm1.
/// </summary>
///
public class WebForm1 : System.Web.UI.Page
{
protected DropDownList cmb1;
protected Label Lbl1;
protected Button Btn1;
protected Table tbl1;
protected DropDownList combo1;
protected TableRow tblrw1;
public WebForm1()
{
Page.Init += new System.EventHandler(Page_Init);
}
private void Page_Load(object sender, System.EventArgs e)
{
Lbl1.Text = "HelloWorld";
}
public void Page_Init(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
private void Btn1_Click(object sender, EventArgs e)
{
Lbl1.Text = "Button Clicked1";
}
#region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.Btn1.Click += new System.EventHandler(this.Btn1_Click);
}
#endregion
}
}
One thing I notice is the handling of the Init event.
The code that is provided by VS.Net doesn't use a constructor
that attaches a handler to the Init event, but uses an override:
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
remove the constructor and the Page_Init method and insert the above code.
The rest of the code looks OK.
Hans Kesting