How can I get the postback argument from initializeRequest event in ASP.NET AJAX
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!
精彩评论