VB.net点击按钮从HTML表单中获取数据

时间:2021-06-26 22:34:54

So with my VB program I need to produce an HTML interface which allows users to insert comments (which will then be stored in an access database).

因此,使用我的VB程序,我需要生成一个HTML界面,允许用户插入注释(然后将其存储在访问数据库中)。

So far I've got the forms, but I have no actual clue what to do after:

到目前为止我已经有了表格,但我没有真正的线索,以后该做什么:

classcontent.Write(<form action="comment_form.asp">Comment: <input type="text" name="comment"></input><br/><input type="submit" value="Submit"></input></form>)

So essentially on the click of the button I need the data inserted into the input to be stored then the page refreshed.

所以基本上单击按钮我需要将数据插入到输入中进行存储,然后页面刷新。

Any ideas?

1 个解决方案

#1


1  

I do not understand your question completely but let me demonstrate you a complete example of submitting values to a web form.

我完全不理解您的问题,但让我向您展示一个向Web表单提交值的完整示例。

Dim myusername As String = txtuser.Text
Dim mypassword As String = txtpass.Text
Dim mycomments As String = txtcomments.Text
WebBrowser1.Document.GetElementById("username").SetAttribute("value", myusername)
WebBrowser1.Document.GetElementById("password").SetAttribute("value", mypassword)
WebBrowser1.Document.GetElementById("comment").SetAttribute("value", mycomments)
WebBrowser1.Document.Forms(0).InvokeMember("submit")

#1


1  

I do not understand your question completely but let me demonstrate you a complete example of submitting values to a web form.

我完全不理解您的问题,但让我向您展示一个向Web表单提交值的完整示例。

Dim myusername As String = txtuser.Text
Dim mypassword As String = txtpass.Text
Dim mycomments As String = txtcomments.Text
WebBrowser1.Document.GetElementById("username").SetAttribute("value", myusername)
WebBrowser1.Document.GetElementById("password").SetAttribute("value", mypassword)
WebBrowser1.Document.GetElementById("comment").SetAttribute("value", mycomments)
WebBrowser1.Document.Forms(0).InvokeMember("submit")