Events on controls in web server control
- by MarkyMarc
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