0

I was wondering if anybody knew how to change the contents of a HTML TextBox with C# I have tried to use body.SetAttribute("value", string) but I did not get anywhere. An example of what I am trying to do is <textarea rows="2" cols="20" id="body" class="messages-reply-box text-box text new-message-body">String I need changed</textarea> Here is what I got so far:

HtmlDocument doc = webBrowser1.Document;
HtmlElement bod = doc.GetElementById("body");
bod.SetAttribute("value", "text");

1 Answer 1

1

If you want change the Text of a Element inside your html page you should use InnerText property. This should work

webBrowser1.Document.GetElementById("body").InnerText ="text";
Sign up to request clarification or add additional context in comments.

2 Comments

It should be webBrowser1.Document.GetElementById("body").InnerText ="text";
Correct, I've copied the wrong tag from my example in VS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.