I am working on an asp.net app and I have some controls dynamically created on the OnInit event I
One of the controls is the asp button that is working fine till now. When I add a ScriptManager
to my page, the same button is unable to postback it is only working when someone takes ScriptManager
out.
Has anyone else been attached to someone else? Am I making the page illegal in any way?
Edit:
This is my script manager tag:
& lt; Asp: ScriptManager id = "ScriptManager1" runat = "server" EnablePageMethods = "true" EnableScriptGlobalization = "true" enabled scriptLocalization = "true" & gt; & Lt; / ASP: ScriptManager & gt; // My Dynamic Button: Button Button 1 = New Button {ID = "Button 1", Text = "OK"}; Button 1 Click + = New Event Handler (button 1_click);
Okay, there is a strange thing. Havent it out because I'm dealing this, but, if the button is inside a container, say, a table cell, then it is capable of posting back. An alternate solution may be
& lt; Form id = "form1" runat = "server" & gt; ; & Lt; Asp: ScriptManager id = "ScriptManager1" runat = "server" EnablePageMethods = "true" Enable ScriptGlobalization = "true" EnableScriptLocalization = "true" /> & Lt; Div & gt; & Lt; P id = "lblClickedFlag" runat = "server" & gt; & Lt; / P & gt; & Lt; Div id = "container" runat = "server" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Form & gt; Protected Zero Page_Init (Object Sender, EventArgs E) {// My Dynamic Button: Button Button 1 = New Button {ID = "Button 1", Text = "OK"}; Button 1 Click the + = Button 1_click; Container.Controls.Add (Button1); } Secure Zero Button 1_Click (Object Sender, EventArgs e) {lblClickedFlag.InnerText = "clicked"; } It works for me
Comments
Post a Comment