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

<<  June 2020  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

View posts in large calendar