views:

76

answers:

5

I have a UpdatePannel Button and a TextBox.Button is inside the UpdatePannel control and the TextBox is out side the pannel control so i want print some text in the TextBox on the button click which is inside the UpdatePannel control.

<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
    <asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>

Any ideas????

I want the TextBox out side the SAME UpdatePannel.Button should be in the UpdatePannel.can i have 2 UpdatePannels.one for the TextBox and another for the Button????

+3  A: 

Put the asp:Textbox inside the UpdatePanel as that is the control that you want to update during postback...

Alexander
+1  A: 

Put the textbox inside the update panel. That's what the panel is for.

Paddy
+2  A: 

A PostBackTrigger will post the page for you:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<Triggers>
     <asp:PostBackTrigger ControlID="Button1" />
</Triggers>

NOTE: As others have mentioned, depending on your requirements, you could just put the TextBox in the UpdatePanel.

rick schott
+1  A: 

You should put the update panel around the TextBox. The button can be inside the update panel but if you don't want it inside the update panel you can use the update panel's triggers and set it the button ID.

Stilgar
+3  A: 

Actually the TextBox should be inside the update panel or outside with an update panel's trigger

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" />   
    </ContentTemplate>
</asp:UpdatePanel>

OR

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
    </ContentTemplate>
    <Triggers>     
        <asp:AsyncPostBackTrigger ControlID="Button1" />     
    </Triggers> 
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" Text="Button" />
Carlos Muñoz
Just by way of further explanation to the OP: The purpose of the update panel is to encapsulate ALL of the controls on the page that you want updated via that ajax call. Anything that is outside of that panel will NOT be updated.
Chris Lively