Using javascript to access asp.net controls

  • Thread starter Thread starter Andy B.
  • Start date Start date
A

Andy B.

I have a DropDownList called SearchByDropDownList. I need to access it's
selected value whenever it changes. If the selectedValue is "date", Disable
the FilterByYearDropDownList (DropDownList control) and the
SearchInRadioButtonList (RadioButtonList control). The javascript needs to
be contained inside of a WebUserControl. This can't have any serverside
coding to it at all. It also can't use ajax. Thanks for the help.
 
When using JavaScript in ASP.NET, you usually need to put a little bit of
extra effort into creating the JavaScript. Here are some of the things you
often need to do differently or that require extra work:

1. Because the id is often generated, you will need to generate part of the
JavaScript by using the ClientId property

2. Controls that do not generate just one HTML element (the RadioButtonList,
for example, generates multiple input elements, each with a different id)
will require you to write some code that determines the ids of the generated
HTML elements. In most cases this will be done through String manipulation.

If you are having trouble getting your JavaScript to work, take a look at
the HTML that your Page generates, and maybe that will help you figure out
what JavaScript you need. Good Luck!
 
I looked at all that sort of stuff. I got the ID for the controls by looking
at the source code. Either way, I still can't get it to work right.
 
In your code, do you create the JavaScript as static code or is it
generated? I may be able to help a little more if I could see what you
currently have.
 
Back
Top