Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Update Multiple UpdatePanels using Javascript

$
0
0

I am trying to update multiple panels 

<asp:UpdatePanelrunat="server"id="UpdatePanel1" UpdateMode="Conditional"OnLoad="UpdatePanel1_Load"><ContentTemplate><!-- Stuff --></ContentTemplate></asp:UpdatePanel><asp:UpdatePanelrunat="server"id="UpdatePanel2" UpdateMode="Always"OnLoad="UpdatePanel2_Load"><ContentTemplate><!-- Different stuff --></ContentTemplate></asp:UpdatePanel>

<asp:UpdatePanelrunat="server"id="UpdatePanel3" UpdateMode="Always"OnLoad="UpdatePanel3_Load">
<ContentTemplate>
<!-- Different stuff -->
</ContentTemplate></asp:UpdatePanel>

And I triggered it in javascript

<script>$(document).ready(function () {            
            //$("#ContentPlaceHolder1_BoxContent_Button1").click();           
            __doPostBack('UpdatePanel1', 'Update-Both');
        });</script>

And the Backend code is 

protected void UpdatePanel1_Load(object sender, EventArgs e)
        {
            if (Request["__eventargument"] == "Update-Both")
            {
                PanelHideShow.Visible = true;

                //update stuff;

                PanelHideShow.Visible = false;
            }            
            //RegisterAsyncTask(new PageAsyncTask(() => Loading()));
        }

        protected void UpdatePanel2_Load(object sender, EventArgs e)
        {
            if (Request["__eventargument"] == "Update-Both")
            {
                PanelHideShow.Visible = true;

                //update stuff

                PanelHideShow.Visible = false;
            }
            //RegisterAsyncTask(new PageAsyncTask(() => Loading()));
        }

        protected void UpdatePanel3_Load(object sender, EventArgs e)
        {
            if (Request["__eventargument"] == "Update-Both")
            {
                PanelHideShow.Visible = true;

                //update stuff

                PanelHideShow.Visible = false;
            }
            //RegisterAsyncTask(new PageAsyncTask(() => Loading()));
        }

I found the control can be updated, however, the codes run keep looping to UpdatePanel1_Load ,UpdatePanel2_Load,UpdatePanel3_Load again and again. What is wrong with my code?


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>