dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: javascript/asp.net dropdownlist

  1. #1
    Join Date
    Dec 2008
    Posts
    11

    javascript/asp.net dropdownlist

    Hi,
    Building my 1st web app so apologies if the question is a bit basic.....

    I have a dropdownlist with autopostback set to true. I want to run a JS function before the postback. When I add the function to the onchange event the postback doesn't fire. I have been using a similar approach with
    asp button controls - but there is a OnClientClick property that either does or doesn't postback depending on whether the JS returns true or false.

    Any help would be greatly appreciated.

    thanks
    Tom

    The code is:

    window.onload = load;

    function load() {
    document.getElementById('DropDownList1').onchange = a;
    }

    function a() {
    //do something
    return true;
    }

    <aspropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="one" AutoPostBack="true">

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    As long as you have set your ASP .NET AutoPostBack, the form will post the value when you change the select's value nomatter the js code. Now what do you want: a JS feature which will act same as AutoPostBack, but only when some conditions are fulfilled (or only after another job is done)?

  3. #3
    Join Date
    Dec 2008
    Posts
    11
    Hi thanks for the reply - am still a bit confused - the code in my original post does not result in a postback - when I remove the JS onclick event the postback is fine. What I want to be able to do is to run some JS code [which will always return true & therefore allow the postback] before the postback happens.
    thanks
    Tom

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles