views:

184

answers:

3

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

A: 

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.

Marc Gravell
... and add an async trigger on the panel containing the textbox, so that clicking on the button will update the text.
Jan Aagaard
A: 

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()

Gabriel Guimarães
+2  A: 

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);
Atzoya