kk1076
kk1076

Reputation: 1748

How to check and stop multiple postbacks for Updateprogress inside an updatepanel

I 'm using a updateprogress control for an updatepanel in my webpage. i specified a condition for updateprogress that only when it gets the corresponding postback element it should load . It works fine only when there is only a single postback element. How to check for other postback elements in the page and enable the updateprogress control. My code as

<style type="text/css">
        .Background
        {
            position: fixed; left: 0; top: 0; z-index: 10; width: 100%;height: 100%;
            filter: alpha(opacity=40);
        }
    </style>
    <script type="text/JavaScript" language="JavaScript">    
        function pageLoad() {    
            var manager = Sys.WebForms.PageRequestManager.getInstance();    
            manager.add_endRequest(endRequest);    
            manager.add_beginRequest(OnBeginRequest);    
        }    
        function OnBeginRequest(sender, args) {    
            var postBackElement = args.get_postBackElement();    
            if (postBackElement.id == 'Button1') {    
                $get('UpdateProgress1').style.display = "block";    
            }
                $get('ParentDiv').className = 'Background';    
        }    
        function endRequest(sender, args) {    
            $get('ParentDiv').className = '';    
        }  </script>

My aspx code as

 <asp:ScriptManager ID="ScriptManager1" runat="server" />
         <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        <div id="ParentDiv">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <td height="403">
                    <iframe id="IFOEvent" name="InIframe" scrolling="auto" runat="server"
                        width="75%" height="203" class=""></iframe>
                </td>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Button1" />
            </Triggers>
        </asp:UpdatePanel>
        </div>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div id="IMGDIV" align="center">
                <img src="Images/loading.gif" alt="" /><br />          
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>

Upvotes: 0

Views: 1443

Answers (2)

Deeptechtons
Deeptechtons

Reputation: 11125

You have more than one method to do that. Why not do this,

  • push set of id's to a array

  • Check during postback if element is in array

  • process as regular async postback

    Code

function pageLoad() { var manager = Sys.WebForms.PageRequestManager.getInstance(); manager.add_endRequest(endRequest); manager.add_beginRequest(OnBeginRequest); }

function OnBeginRequest(sender, args) { var map = ["Button1", "Button2", "Button3"]; var postBackElement = args.get_postBackElement(); if (map.indexOf(postBackElement.id) !== -1) { $get('UpdateProgress1').style.display = "block"; } $get('ParentDiv').className = 'Background'; }

Upvotes: 1

mehmood
mehmood

Reputation: 2600

Set a variable and change its value end Request method for example

var temp = 0;

function endRequest(sender, args) {
if(temp == 0) {
$get('ParentDiv').className = '';
temp ++; } else { temp = 0; } }

you can also use hidden file to set value.

Upvotes: 0

Related Questions