Using javascript to access asp.net controls

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.
 
N

Nathan Sokalski

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!
 
A

Andy B.

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.
 
N

Nathan Sokalski

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top