在PageRequestManager请求中调用捕获服务器端事件 [英] Catch server side event being called in PageRequestManager request

查看:83
本文介绍了在PageRequestManager请求中调用捕获服务器端事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我意识到您可以获取ajax调用请求的postbackelement:

Hi all,

I realise you can get the postbackelement of the ajax call request:

<br />
<pre>Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);<br />
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);<br />
function BeginRequestHandler(sender, args) {<br />
    var elem = args.get_postBackElement();</pre><br />
<br />



有谁知道我是否也可以尝试调用服务器端事件?

我要达到的目标(可能更有意义):

我在页面上有2个更新面板,updatepanel1具有gridview并将属性"ChildrenAsTriggers"设置为false. UpdatePanel2已放入隐藏的浮动div(看起来像模式弹出窗口)中,并且其触发器已设置为GridView1.SelectedIndexChanged.我捕获了PageRequestManager(beginrequest)中的元素,如果它是GridView,则显示包含updatepanel2的div.

在我希望允许对GridView进行排序之前,这一切都很好,当我不希望这样做时,显然会显示updatepanel2.我需要做些什么:



Does anyone know if I can get the server side event it''s trying to call also?

What I''m trying to acheive (might make more sense):

I have 2 update panels on a page, updatepanel1 has a gridview and the property ''ChildrenAsTriggers'' set to false. UpdatePanel2 has been put in a hidden floating div (looks like a modal popup) and it''s trigger has been set to GridView1.SelectedIndexChanged. I capture the element in PageRequestManager (beginrequest) and if it''s the GridView then I show the div containing updatepanel2.

This is all working great until I want to allow sorting on the GridView which obviously shows updatepanel2 when I don''t want it to. I need to somehow do:

<br />
<pre>function BeginRequestHandler(sender, args) {<br />
    var elem = args.get_postBackElement();<br />
    if (elem is GridView1 and event being called is selectedindexchanged)</pre><br />



但是似乎无法轻松找到正在调用哪个事件.

任何帮助,将不胜感激.谢谢

Gav



However can not seem to easily find which event is being called.

Any help would be appreciated. Thanks

Gav

推荐答案

也许不是最优雅的方法,但是我设法使用以下方法实现了目标:

Perhaps not the most elegant way but I''ve managed to acheive my goal by using:

document.getElementById("__EVENTARGUMENT").value.indexOf("Select


")!=-1



如果还有其他/更好的方法,仍然愿意接受建议吗?!
干杯



Still open to suggestions if there is a different/better way?!
Cheers


这篇关于在PageRequestManager请求中调用捕获服务器端事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆