using System; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; namespace SampleControls { /// <summary> /// Summary description for SimpleControl. /// </summary> [DefaultProperty("Text"), ToolboxData("<{0}:kaSimpleControl runat=server></{0}:SimpleControl>")] public class SimpleControl : System.Web.UI.WebControls.WebControl, IPostBackEventHandler { protected string text = "Sample"; [Bindable(true), Category("Appearance"), DefaultValue("")] public string Text { get { return text; } set { text = value; } } protected override void Render(HtmlTextWriter output) { string sampleHTML = "<b>" + this.text + "</b>"; output.Write(sampleHTML); } public void RaisePostBackEvent(string eventArgument) { this.text = "Postback occurred."; } } }Then I modified the HTML code to add the control:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="TestPostback.WebForm1" %> <%@ Register TagPrefix="cc1" Namespace="SampleControls" Assembly="TestPostback" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:ImageButton id="ImageButton1" style="Z-INDEX: 101; LEFT: 241px; POSITION: absolute; TOP: 207px" runat="server" Width="60px" Height="26px"></asp:ImageButton> <cc1:SimpleControl id="SimpleControl" runat="server"> </cc1:SimpleControl> </form> </body> </html>The form runs OK, but the PostBackEvent still doesn't fire (even with a breakpoint set). Any other ideas?