开发者

Fill html textarea with c# webbroser

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜