c# - Assigned text to label doesn't get updated -


so function serves ajax call:

public void button1_click(object sender, eventargs e)         {             button1.text = "surprise";             label1.text = "surprise!!";             label2.text = "surprise!!";         } 

this aspx. scriptmanager set.

    <p>síðast slóstu inn:         <asp:label id="label1" runat="server" text=""></asp:label>         <asp:label id="label2" runat="server" text=""></asp:label>     </p>     <asp:updatepanel id="updatepanel1" runat="server">         <contenttemplate>             <asp:textbox id="textbox1" runat="server">asd</asp:textbox>             <asp:textbox id="textbox2" runat="server">dsa</asp:textbox>             <asp:button id="button1" runat="server" text="save" onclick="button1_click" />         </contenttemplate>     </asp:updatepanel> 

you can see yourselves if want: http://webapplication44730.azurewebsites.net/data

as can see, button text changes "surprise" labels, label1 , label2 should appear after 'inn,' don't.

the cause labels not inside updatepanel, means not updated ajax callback.

set update panel around every control need update:

<asp:updatepanel id="updatepanel1" runat="server">     <contenttemplate>         <p>síðast slóstu inn:             <asp:label id="label1" runat="server" text=""></asp:label>             <asp:label id="label2" runat="server" text=""></asp:label>         </p>         <asp:textbox id="textbox1" runat="server">asd</asp:textbox>         <asp:textbox id="textbox2" runat="server">dsa</asp:textbox>         <asp:button id="button1" runat="server" text="save" onclick="button1_click" />     </contenttemplate> </asp:updatepanel> 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -