ASP.NET Server Controls
Hi,
I'm trying to create a very simple ASP.NET server component without compiling. I'm basing my test control off of an example in Wrox's "ASP.NET Server Controls (Building Custom Controls with C#)".
Here is what I have
File = test.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Steve
{
public class Test : Page
{
private Button b = new Button();
protected override void CreateChildControls()
{
b.Text = "Before Click";
Controls.Add(b);
b.Click += new EventHandler(this.Clicked);
}
private void Clicked(Object sender, EventArgs e)
{
b.Text = "After Click";
}
}
}
File - test.aspx
<%@ Page Language = "C#" Inherits = "Steve.Test" Src = "test.cs" runat = "server" %>
<html>
<body>
Will my button work? <br>
</body>
</html>
When I run this page, the button display, but I can't get the "Clicked" event to fire. Nothing happens when I click on the button. Any ideas why?
Thanks
-Steve
|