Get Html Input Controls Value Server Side in ASP.Net


Get Html Input Controls Value Server Side in ASP.Net

Obtain a value of an input (type text) on server side

Sometimes we need to create html controls dynamically on page and whenever some events raised like button or image button click event on server side code and we need to retrieve the values of those html controls as it is not declared as runat="server" on the page.

Here is the simple way to get values of the html input controls which doesn't have runat="server" attribute defined. Find the source code below:-
get html control values server side in, c#, without using runat="server",html control,  server side
C# - How to get value in html control on PostBack in ASP.Net
<input type="text" name="_name"  />       
<asp:Button ID="btnShow" runat="server" Text="Show" onclick="btnShow_Click" />

protected void btnShow_Click(object sender, EventArgs e)
            string strValue = Page.Request.Form["_name"].ToString();

Note: To get the values on server side code of HTML control, we need to follow below points:
  • The tag should have an attribute called NAME. Because it is used as key in form[].
  • The form method should be of type POST.
I hope you will enjoy the development tips while programming with ASP.NET. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome. 

Also If you like this article, don't forget to share this article with your friends and colleagues.
Get Html Input Controls Value Server Side in ASP.Net Reviewed by Ravi Kumar on 12:09 AM Rating: 5


  1. Its giving me Object reference not set to an instance of an object. Error, Why???

    1. It works fine with html input controls only. If you getting "Object reference not set to an instance of an object" error, to resolve this problem check your connection data source ..!!

  2. I get the value its working fine thanks. But How to get the control type ? also ?

  3. Hi Ravi,

    It' works fine....

    Thanks lot brother ............


All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form


Email *

Message *

Powered by Blogger.