i am having a Page.in that page button inside a UpdatePanel.when a user click on the button. i need to assign a value to textbox which is outside of the updatepanel.
how to achieve this ? any suggestion it will be there ?
Thanks & Regards Ravikumar
i am having a Page.in that page button inside a UpdatePanel.when a user click on the button. i need to assign a value to textbox which is outside of the updatepanel.
how to achieve this ? any suggestion it will be there ?
Thanks & Regards Ravikumar
IIRC You would need to call .Update() on the additional controls (perhaps placing them in a second UpdatePanel and calling .Update() on that). See MSDN for an example.
Place the TextBox in a updatepanel with a trigger to the button here's a example:
<asp:UpdatePanel ID="upd1" runat="server">
<ContentTemplate>
<asp:Button ID="Btn1" runat="server />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="upd2" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtBox1" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Btn1" />
</Triggers>
</asp:UpdatePanel>
And on the Button Click, you can change the value of txtBox1 and call upd2.Update()
You can also place the TextBox in a Update panel, leave the button out of the update panel and set a trigger that will cause the button to do a Async postback like this:
<asp:Button ID="btnSubmit" runat="server />
<asp:UpdatePanel ID="upTextBox" runat="server">
<ContentTemplate>
<asp:TextBox ID="tbTitle" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" />
</Triggers>
</asp:UpdatePanel>
And then add a button event that will change the text of the text box.
Or if you don't want to add the text box in a Update Panel you can register a startup script to set the text of the textBox something like this:
ScriptManager.RegisterStartupScript(this, GetType(), "setTextBoxText", "<script type='text/javascript'>$('#"+tbTitle.ClientId+"').val('submit button has been clicked');</script>", false);