Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery dropdown selector AutoPostback

Tags:

jquery

asp.net

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 
        }  

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

like image 755
Victor Avatar asked Feb 04 '10 23:02

Victor


1 Answers

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...);
like image 141
Jarrett Widman Avatar answered Oct 05 '22 23:10

Jarrett Widman