Events on controls in web server control

Posted by MarkyMarc on Stack Overflow See other posts from Stack Overflow or by MarkyMarc
Published on 2010-06-07T15:44:20Z Indexed on 2010/06/07 15:52 UTC
Read the original article Hit count: 220

Hi All,

I'm creating a web server control that has an image button on it. The html for the control is done in the RenderControls of the code, the control devrives from WebControl, IScriptControl, INamingContainer.

The button is coded as follow in the RenderControls:

System.Web.UI.WebControls.ImageButton img = new System.Web.UI.WebControls.ImageButton(); img.ImageUrl = "Url of the image"; img.Click += new ImageClickEventHandler(img_Click); img.ID = this.ClientID + "_img"; img.CausesValidation = false; imgLock.RenderControl(output);

The button apreas in the browser but when i click on it, the page postsback but the event handler for the button doesn't get fired, from what i can figure out, since the control goes throught RenderControls eachtime the page is posted back, the button gets redrawn and the event handling disapears.

This server control is in a master page.

Anyone can help me on this?

Thanks

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about web-development