开发者

Fill html textarea with c# webbroser

开发者 https://www.devze.com 2023-04-11 20:34 出处:网络
I need to fill textarea u开发者_开发技巧sing webbrowser. I can\'t use getElementByID as there\'s no id in textarea, just name, here\'s textarea code:

I need to fill textarea u开发者_开发技巧sing webbrowser. I can't use getElementByID as there's no id in textarea, just name, here's textarea code:

<textarea name="txt1"></textarea>

thanks..


If you cannot get elements by ID, you can always iterate elements by tagname

foreach (HtmlElement element in webBbrowser1.Document.GetElementsByTagName("textarea"))
{
     // access text area element here
}


You could try something like this:

var elements = document.getElementsByName("txt1");
if (elements.length > 0){
    var txt = elements[0];
    if (txt){
        txt.value = "Hi";
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号