Results 1 to 3 of 3

Thread: javascript/asp.net dropdownlist

  1. #1
    Join Date
    Dec 2008

    javascript/asp.net dropdownlist

    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.


    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
    Bucharest, ROMANIA
    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
    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.

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