简体   繁体   English

VB.NET WebBrowser取得textarea值

[英]VB.NET WebBrowser Take textarea value

I can not take the value from a web textarea the code is as follows 我无法从网络textarea中获取值,代码如下

<input type="text" name="ID1" id="subject" size="20" value="TEST1" />

<input type="text" name="ID2" id="subject" size="20" value="TEST2" />

I want to insert the value TEST1 and TEST2 in a vb.net form and show messagebox with the value thanks I hope you can help me, I beg your pardon for my bad English 我想在vb.net表单中插入值TEST1和TEST2并显示带有该值的消息框谢谢,我希望你能帮助我,请原谅我的英语不好

The name field does not really matter. 名称字段并不重要。 You want the id field to be different. 您希望id字段不同。 You can keep them the same if you want. 如果需要,可以将它们保持不变。 Try this: 尝试这个:

<input type="text" name="ID1" id="ID1" size="20" value="TEST1" />

<input type="text" name="ID2" id="ID2" size="20" value="TEST2" />

I'm not sure what you mean by show messagebox. 我不确定显示消息框的含义。 Are you talking about a javascript alert() call? 您是否在谈论javascript alert()调用?


Also, note this is not actually VB.NET. 另外,请注意,这实际上不是VB.NET。 The code you have posted is just html. 您发布的代码只是html。 If you want to interact with the values on the serverside you would need code that looks something like this in your aspx page: 如果要与服务器端的值进行交互,则需要在aspx页面中看起来像这样的代码:

<asp:TextBox id="id1" columns="20" text="Test1" runat="server" /> 
 Dim HtmlElementcoll As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("textarea")
        For Each elem As HtmlElement In HtmlElementcoll
            ' Check the attributtes you want
            If elem.GetAttribute("name") = "status" Then
                'Check even the text if you want
                ' If elem.InnerText = "Sign In" Then
                'Invoke your event
                elem.SetAttribute("value", "hey")

                'elem.InvokeMember("click")

                'End If
            End If
        Next

you can fill a textbox without an id like this i have used getAttribute method to get the name of the field and setAttribute to set the value of the textbox. 您可以填充没有ID的文本框,例如这样,我已经使用getAttribute方法获取字段的名称,并使用setAttribute设置文本框的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM