.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Get HTML form control value in server side

Posted By: saipavan     Posted Date: June 16, 2010    Points:2   Category :ASP.Net
i taken one html page in asp.net,in that i taken some form controls like textboxes,labels and submit buttons.now my problem is can i retrive those controls in aspx.cs page. how to proceed....!

Author: Amit Mehra             
Posted Date: June 16, 2010     Points: 5   


You have HTML control, replace that with asp.net web server controls in order to get the value at the server side


Just add runat="server" in the control tag

for eg

<input type="textarea" id="txtName" runat="server"/>

Please "Mark As Answer " if this post help you.
Author: saipavan             
Posted Date: June 17, 2010     Points: 5   

already i have add runat="server" but no use pls another solution

Author: Lakhan Pal Garg             
Posted Date: June 17, 2010     Points: 5   

Hi amit-
First try with txtName.Value on server side. if still it is not working then add one hidden field on the page and save the value of html textarea in hidden field using javascript and then access hidden field value at server side.

Lakhan Pal Garg

Author: JH             
Posted Date: June 18, 2010     Points: 5   


if you are using HTML control and need to server-side. you should find controls in server-side.

We have option in Server-side,using FindControl() and can easy to access htmlcontrols in server-side



Author: Syed Shakeer Hussain             
Posted Date: June 20, 2010     Points: 5   

use the follwoing code
<SCRIPT LANGUAGE="javascript">
function meth()
var txt= document.getElementById(txt_name);

<INPUT TYPE="text" NAME="FirstName" id="txt_name">
<INPUT TYPE="submit" VALUE="Click and See" onclick="meth()">

Author: IronCoder             
Posted Date: August 19, 2010     Points: 5   

Hey Folks,

I've been messing with this problem for a while here. Recall that HTML must have unique NAME values for any control you're going to send via your postback. These names are associated with the data. Therefore,

<INPUT Type='text' Name='myTxt' ... >

When you want to get this information, you can do the following:

If isPostBack THEN
Dim myTxt as String = Page.Request.Form('myTxt').ToString()
End If

No runat='server' needed.


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend