Get value of html Input box in asp.net

Solution

Type following code in .aspx page

<input id=”txt1″ name=”txt1″ type=”Text” /><br />

<asp:Button ID=”Button1″ runat=”server” Text=”Button” onclick=”Button1_Click” />

Type following code in .aspx.cs or code behind

protected void Button1_Click(object sender, EventArgs e)
{
string n = Request["txt1"];
Response.Write(n);
}

 

About the Author

avatar