jQuery的下拉菜单中选择自动回发 [英] jquery dropdown selector AutoPostback

查看:125
本文介绍了jQuery的下拉菜单中选择自动回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jQuery是有什么办法postbacking下拉列表和非postbacking的人(ASP.NET 3.5)来区分:

In jQuery is there any way to distinguish between postbacking dropdowns and non-postbacking ones(ASP.NET 3.5):

$('select').change(function(e)
{
        //something like this
        if ($(this).attr('AutoPostback') == true) 
        { 
           //do something here  

        } 
       else  
        { 
          //do something else 
        }  

想到要在这里从脚本中调用服务器端函数来确定的AutoPostBack。

Think have to call server side function from script here to determine AutoPostback.

推荐答案

通常,将会回传将有一个包含类似的onchange属性下拉__doPostBack(虽然有也将有一些其他的东西。

Typically, a dropdown that is going to postback will have an onchange attribute that contains something like "__doPostBack(" though there will also be some other stuff in there.

所以,你可以做类似下面,我没有测试,所以希望有没有错别字

So you could do something like the below, which I didn't test so hopefully there is no typos

$('select[onchange*="__doPostBack("]').change(...your handler for postbacking control...);
$('select:not([onchange*="__doPostBack("])').change(...your handler for non-postbacking control...);

这篇关于jQuery的下拉菜单中选择自动回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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