开发者

How can I get the postback argument from initializeRequest event in ASP.NET AJAX

开发者 https://www.devze.com 2023-01-29 16:39 出处:网络
I capture the initializeRequest AJAX event using Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(I开发者_运维知识库nitializePostback).

I capture the initializeRequest AJAX event using Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(I开发者_运维知识库nitializePostback).

Inside the InitializePostback function, I can successfully get the item that triggered the postback by calling args.get_postBackElement(), but this is not enough info for me, I also need to get the postback argument that was sent with the postback. How can I do this?


OK, I found out what I need to do. Because the postback event argument is allways stored in a hidden tag named "__EVENTARGUMENT", we can simply access that:

var postbackArgument = document.getElementById('__EVENTARGUMENT');
if (postbackArgument) if (postbackArguments.value == 'Objects') {
 // Do stuff here
}

I was not sure if this value was set at the time the initializeRequest AJAX event was triggered, but when I tried it worked. Yess!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号