locked
UpdatePanel Do Full postback on Dynamic WebControls RRS feed

  • Question

  • User1449651191 posted

    Hello 

    I am searching for a solution for over 20 days,  The problem appears only when I load Web Users Controls as Dynamic in the Default.aspx,

    If I add the by drag it into the page as Static , there is no problem.  

    This is how the code in default.aspx for static (fixed) 

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <uc1:WebControl1 runat="server" ID="WebControl" />
    </asp:Content>



    I have a Masterpage and Default.aspx and many web controls, 

    I add ScriptManager in the MasterPage as following 

    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager>
    <div>
    <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
                                             
    </asp:ContentPlaceHolder>
    </div>
    </form>
                                                   

    and I added the Following in the Default.aspx Page 

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
        
    </asp:Content>
        
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
     
    </asp:Content>


    I used the following code in the Default.aspx.cs (Code Behind) File to load the pages based on passed parameters 

     // find the place holder
    ContentPlaceHolder mainContent = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
     // load the control
    //page name is the webcontrol name and its source
    Control MyControl = (Control)LoadControl(pagename);
    // add the control
    mainContent.Controls.Add(MyControl);

    I used the following code in the Webcontrol.ascx 

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
    
    some controls such as datagrid, buttons and dropdowns 
    
        </ContentTemplate>
                        </asp:UpdatePanel>

    and in the code behind 

     if (IsPostBack == true)
            {
     
                ScriptManager.GetCurrent(Page).RegisterPostBackControl(Submitbtn);
            }

    I hope I can find solution like everytime. 

    Thanks 

    Thursday, September 1, 2016 9:03 PM

Answers

  • User-1142886626 posted

    Hi Ahmad Jaber,

    If you add an UpdatePanel control to your page, you can achieve a partial-update of your page on a postback. Only the content in the UpdatePanel is refreshed. So, when controls that are placed inside an UpdatePanel of a custom web control cause the whole page to raise a post back. You could make sure each control inside the update panel have an id. After all the controls inside the update panel are assigned ids, the controls inside the UpdatePanel won’t cause the page to raise post backs anymore.

    Besides, you could refer the following link. Hope be helpful with you.

    http://forums.asp.net/t/1397053.aspx

    http://stackoverflow.com/questions/14897618/problems-with-the-updatepanel

    Best Regards,

    Ailleen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 5, 2016 9:14 AM