Getting a parameter value from a TextBox control

Certify and Increase Opportunity.
Be
Govt. Certified ASP.NET Programmer

Getting a parameter value from a TextBox control

TextBox control displays a text box control for user input. Usage in ASP.NET is as
<asp:TextBox />
The public property ‘Text’ gets or sets the text content of the TextBox control.
TextBox Value by JavaScript
Following code will render a TextBox and a Button control.

aspx page code
<table>

<tr>

<th colspan=”2″ align=”left”>

Getting TextBox Value in JavaScript:

</th>

</tr>

<tr>

<td>

<asp:TextBox ID=”txt1″ runat=”server”></asp:TextBox>

</td>

<td>

<input type=”button” value=”Submit” onclick=”GetTextBoxValue(‘<%= txt1.ClientID %>’)” />

</td>

</tr>

</table>

Following code is JavaScript function to get value from TextBox control.

JavaScript function
// Get TextBox value

function GetTextBoxValue(id)

{

alert(document.getElementById(id).value);

}

Get industry recognized certification – Contact us

Menu