How to get the ID refresh panel that initiates the request in javascript

I want to know the ID refresh panel that initializes the request in JavaScript. I am writing this script, but it returns undefined

.

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);

function InitializeRequest(sender, args) {
    alert(sender.ID);
}
function EndRequest(sender, args) {
}

      

sender

is not null and returns [object]

, but how can I get ID

?


Edit 1)

I think when UpdatePanel

inside MasterPage

, it doesn't work. This is my code:

<script type="text/javascript">
    $(document).ready(function () {
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_initializeRequest(InitializeRequest);
        prm.add_endRequest(EndRequest);


        function InitializeRequest(sender, args) {
            var UpdPanelsIds = args.get_updatePanelsToUpdate();
            alert(UpdPanelsIds[0]);
        }
        function EndRequest(sender, args) {
            if ($('.AlarmLogo').val() == "3") {
                alert('nima');
            }
        }
    });


</script>

      

and:

<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="timer" Interval="4000" runat="server" OnTick="timer_Tick" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Panel ID="pnlAlarm" runat="server" CssClass="pnlAlarm" ClientIDMode="Static">
            <a href="#">
                <div id="Alarm">
                    <asp:TextBox ID="lblContent" runat="server" Text="HHHEEELLLOOO" CssClass="AlarmLogo" ClientIDMode="Static"></asp:TextBox>
                </div>
            </a>
        </asp:Panel>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="timer" />
    </Triggers>
</asp:UpdatePanel>
    <div class="main">
        <asp:ContentPlaceHolder ID="MainContent" runat="server" />
    </div>
</form>

      

and the code behind:

protected void Page_Load(object sender, EventArgs e) 
{     
    if (!IsPostBack)     
    {         
        Session["nima"] = 1;    
    } 
} 

protected void timer_Tick(object sender, EventArgs e) 
{    
} 

      

+2


source to share


1 answer


You can use get_updatePanelsToUpdate

that return an array with the IDs of the panels being updated to be updated.

<script>
    window.onload = function() {
        var prm = Sys.WebForms.PageRequestManager.getInstance();

        prm.add_initializeRequest(InitializeRequest);
        prm.add_endRequest(EndRequest);
    };

      function InitializeRequest(sender, args) 
      {     
         // get the array of update panels id
         var UpdPanelsIds = args.get_updatePanelsToUpdate();
         // get the Post ID
         args.get_postBackElement().id;
      }

      function EndRequest(sender, args) {
      }
</script>

      



http://msdn.microsoft.com/en-us/library/ee224805.aspx

+5


source







All Articles