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

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

How to get input of a html text area control in asp.net code behind ?

Posted By: ASPEvil     Posted Date: November 09, 2010    Points:2   Category :ASP.Net

I am using a HTML TextArea control which is not declared as runat="server" and I am also not wanting to declare it as runat="server" too as there are some reasons.
Now, I want to get the user input in this text area control in the code behind of the asp.net. How can I do this?

Author: Asha.MP             
Posted Date: November 09, 2010     Points: 5   


I think If you dont add the runat=server tag in the html control, it is not posible to get the controls.

Thanks and Regards,
Author: Asha.MP             
Posted Date: November 09, 2010     Points: 5   


Yes You can get and set the value of html controls in code behind.
Below code is in aspx page.
<table >
<td><input id="txtDesc1" name="txtDesc1" type="text" value="Set in Client Side" /></td>
<td> <input id="txtDesc2" name="txtDesc2" type="text" value="<%=ServerValue %>" /></td>
<td><asp:Button ID="BtnClick" runat ="server" Text ="Click" /></td>

To this in the code behind declare the variable ServerValue as public variable like
Public ServerValue As String = String.Empty

In the events like buttonclick write below code, Here i am using button click event of asp page.
Private Sub BtnClick_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnClick.Click
Dim ClientValue As String = Request.Form("txtDesc1")
ServerValue = "Set in Server"
End Sub

Like this you can get and set the value

Thanks and Regards,
Author: ASPEvil             
Posted Date: November 10, 2010     Points: 5   

Hello Asha.MP,

Thanks for your reply. But your code does just the reverse of my need. Actually, I am wanting to get the input text of a text area control which is not declared as "runat=server", in the code behind and your code is for setting the text of textbox control from server side.

So, can you please let me know how to resolve my problem?

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