Click here to Skip to main content
16,020,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Suppose I had the following HTML:
HTML
<html>
    <body>
       <textarea id="foo"></textarea>
    </body>
</html>

How to insert Text into the TextArea through C# Htmldocument?
The SetAttribute() method is not working as there is no value field for TextArea
So how to insert Text into TextArea through C#?

Any advice is much appreciated!

Thanks in advance.
Posted
Updated 18-Mar-12 3:08am
v2
Comments
ProEnggSoft 18-Mar-12 9:08am    
Edit: code tags introduced - PES

C#
<textarea id="foo" runat="server"></textarea>

Then use this propriety InnerText
and for applying HTML tags use InnerHtml

C#
foo.InnerText = "  ";
 
Share this answer
 
Comments
Murthy Vemparala 18-Mar-12 10:02am    
Thank you Mohamed Mitwalli but that html page is already hosted with this "textarea" tag.

<textarea id="foo"></textarea>

So I cannot modify the page,is there any other way to set the text to textarea?
 
Share this answer
 
Comments
Murthy Vemparala 18-Mar-12 9:27am    
Thank You Wes,I looked through the link but the problem is the html page is already hosted which I cannot modify so I cannot add runat="server".
Is there any other way to insert text into Textarea through C# code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900