Friday, July 9, 2010

Use JavaScript to hide an ASP.Net Button

To be 508 compliant, my page must allow users to select items from a drop-down list with JavaScript disabled, so I added a “select” button (called btnAgSelect) next to the list.  When JS is enabled, I do not want the button to be visible, so I used this in my Page.Load() event:

 

ScriptManager.RegisterStartupScript(

  this ,this.GetType(),

  "", "document.getElementById('" +

  btnAgSelect.ClientID + "').style.visibility='hidden';",

  true);

No comments: