Search code examples
asp.netvb.netupdatepanelpostbackautopostback

How do I force asp.net page to postback when I'm in code behind that called by UpdatePanel


When an UpdatePanel Calls a method in server and for example this method change

textBox1.Text = "12312"

and this textBox1 was out of updatePanle scope it dosn't change it text till a postback happend to the page

so I need after that calculation and chaging the Textbox's text in the server, I need to forcepage to do postback

plz can any one help ?


Solution

  • If you wish for a control within the UpdatePanel to perform a standard postback, define a PostBackTrigger within the UpdatePanel, setting the ControlID to the ID of the control you wish to perform the postback.

    <asp:UpdatePanel ...
    
         ...
    
        <Triggers>
            <asp:PostBackTrigger ControlID="ControlIDToPostBack" />
        </Triggers>
    </asp:UpdatePanel>
    

    Or you could add the TextBox control you wish to update to another UpdatePanel setting both of the UpdatePanel's UpdateMode properties to Always.

    This will ensure that the content within both UpdatePanel controls is updated for all postbacks that originate from the page. Which includes asynchronous postbacks.

    <asp:UpdatePanel ... UpdateMode="Always"