Hi,
I got trouble when I want to add my custom control with an gridview and an updatePanel. The javascript function is never added to the page even if I write it directly inside the RenderContent method.
The page is :
UpdatePanel GridView EditItem CustomControl
"
SelectCommand="SELECT * FROM [APP_ROLE]">
The custom constrol looks like that :
[ToolboxData("<{0}:TestControl runat=server>")] public class TestControl : WebControl { protected override void OnInit(EventArgs e) { base.OnInit(e);
string script = "<SCRIPT type=\"text/javascript\">\n" +
"function show_" + ClientID + "(){alert('toto');}" +
"</SCRIPT>\n";
if (Page.ClientScript.IsClientScriptBlockRegistered("show_" + ClientID))
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "show_" + ClientID, script);
}
protected override void RenderContents(HtmlTextWriter writer)
{
writer.WriteLine("<a href=\"javascript:show_" + ClientID + "();\">click</a>");
}
}
Can anyone help me ?
Cheers.