Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi....
how to get the Textbox value by using the javascript
Posted

Suppose you have a textbox like as:

ASP.NET
<asp:textbox id="txtMyTextBox" runat="Server" text="1234" xmlns:asp="#unknown"></asp:textbox>


Javascript way of accessing it:

JavaScript
var value = document.getElementById('<%=txtMyTextBox.ClientID%>').value;


As TextBox is server control, so on runtime this control have different client id

JavaScript
'<%=txtMyTextBox.ClientID%>' 
will return control clientid on runtime
 
Share this answer
 
Comments
Kuthuparakkal 13-Sep-12 0:04am    
you're welcome!
mahesh202 13-Sep-12 0:04am    
what is the use of creating control dynamically
Kuthuparakkal 13-Sep-12 0:11am    
Suppose you have an action that's determined at run time, then you create control that defines your action to perform. Look at:
http://bytes.com/topic/asp-net/insights/750415-how-use-dynamic-controls-asp-net
mahesh202 13-Sep-12 0:20am    
please to give an answer for this
once see the site (http://www.aspsnippets.com ) in this page have some linked buttons in blue color , if i put the mouse in any button it will change their color and show some content
so how to write the code for this i need to develop this kind of application please give the code ....
Kuthuparakkal 13-Sep-12 1:31am    
it's simple ASP.Net Menu with Submenus are displayed on Mouse Hover property. You may use the following article on menu:
http://www.codeproject.com/Articles/47515/ASP-NET-Horizontal-Menu-Control

Also once you create menu, set Mouse Hover Property:
http://forums.asp.net/t/1502837.aspx/1
Assuming you have the attribute id="myTextBox" in HTML like
HTML
<input type="text" id="myTextBox">

you can get the value using JavaScript like
JavaScript
myTextBox = document.getElementById("myTextBox");
value = myTextBox.value;


—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900