0

Sorry for the basic silly question. But I really dont have any idea on solving this. I have ASP controls (One Text Box and One Drop Down List). Now I need to access value property of TextBox as well as SelectedIndex property of dropdown list. This should be as simple as:
for TextBox:

document.getElementById('<%= myControl.ClientID %>').value

for DropDown List:

document.getElementById('<%= myControl.ClientID %>;').selectedindex

But in Visual Studio 2008, while I am writing these codes, it does not work. I can not find any value or selectedindex attribute for the respective control. I am not getting this, because in most forums and tutorials, they suggested in a simple way I mentioned.

Is there any other way or I am just missing something here? Please help me out. Thanks in advance

Edited by jchoudhury: n/a

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Airshow
0

Intellesense will not show these values as it can't compile the value of <%=myControl.ClientID%> on the fly as it is server side. Try out the code and use alerts to determine if you are getting what you need.

this is wrong "document.getElementById('<%= myControl.ClientID %>;').selectedindex" remove the ;

0

1. In your browser, View Source of the served page. Is the source what you expect, with <%= myControl.xxxxx %> directives successfully substituted, and do these ids correspond to those of the element(s) in the HTML?

2. The current value of your <select> menu should be given by :-

var el = document.getElementById('<%= myControl.ClientID %>');
var value = el[el.selectedindex].value;

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.