Send text to textarea in webbrowser
i have a webbrowser component in a windows application.
could anybody please tell me how to send text to textboxes i开发者_JAVA技巧n webpages appearing in this browser programatically?
my HTML code
<textarea name="message" id="vB_Editor_QR_textarea" rows="10" cols="60" style="width:100%; height:100px" tabindex="1" dir="ltr"></textarea>
Edit: Edit: Can you post your code?? I tried and it worked.
I added a WebBrowser control and during Form Load I set the HTML
webBrowser1.DocumentText = "<textarea name='message' id='t' rows='10' cols='60' style='width:100%; height:100px' tabindex='1' dir='ltr'></textarea>";
Added a button and added the following code for Button Click event
HtmlElement el = webBrowser1.Document.All["t"];
el.InnerText = "Hello World";
and it works.
WebBrowser has Document property using which you can achieve your requirements. For example to click a button you can use the following code
HtmlElement el = webBrowser1.Document.All["btnI"];
if (el != null) el.InvokeMember("click");
Sample code is copied from here
WebBrowser Class documentation
Hope this serves as a starting point. Try it and If you have any specific issues. Update your question and we will help.
精彩评论