Oct
23
2012
ASP.NET // C#

Get html input text values in asp.net C# code behind

Here is how to get html input text values with out having runat="server" from asp.net c# code behind.

 

Example:

 

Front-end (.aspx) page:

<input type="text" id="text1" name="text1" />

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

 

Back-end (.aspx.cs) page: 

protected void Button1_Click(object sender, EventArgs e)

{

string getTextValues = Request["text1"].Trim(); 

}

 

 OR:

protected void Button1_Click(object sender, EventArgs e)

{

string getTextValues = Page.Request.Form["text1"].ToString(); 

}

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Calendar

<<  August 2020  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar