views:

388

answers:

2

I am disabling a dropdownlist when a button is clicked

function disableDropDown(DropDownID)
{
  document.getElementById(DropDownID).disabled = true;
  return false; <---------tried with and without this, no luck
}

and a onClick call to

disableDropDown('DropDownID');

I see it disable the dropdown and then immediately there is a postback happening which enables it back. Can someone explain what might be wrong here?

A: 

Is an ASP.NET Button control calling it? That's probably why your page is posting back.

Try just using a regular html input button.

<input type="button" onclick="disableDropDown('DropDownID');" />

Aaron Daniels
I think the asp.net button control contains a OnClientClick parameter as well.
Dave
A: 

it sounds like you might have this attached to an asp:Button which is posting back.

All you really need is an <input type="button"> or even just a <button> element

<button onclick="disableDropDown(DropDownID);">Disable DropDown</button>
Russ Cam