[英]Submit value to html textbox with awesomium - vb.net
我正在使用此代碼從列表框拆分文本:
For Each Item As Object In ListBox1.SelectedItems
TextBox2.AppendText(Item.ToString + Environment.NewLine)
Next
Dim str As String = TextBox2.Text
Dim leftPart As String = str.Split(":")(0)
Dim test As String = TextBox2.Text
Dim phrase As String = test.Substring(test.IndexOf(":"c) + 1)
和此代碼將值提交到html文本框
WebControl1.ExecuteJavascript("document.getElementById('email').value=""" + leftPart + """;")
Dim leftpar2 As String
leftpar2 = phrase
MsgBox(phrase)
Try
WebControl1.ExecuteJavascript("document.getElementById('pass').value=""" + leftpar2 + """;")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
具有ID(電子郵件)的文本框可以正常工作
但是另一個(通過)總是空的,我試圖彈出(短語)的值它得到正確的值
我試圖將字符串分配給變量(詞組)
Dim phrase As String = "test"
它工作正常,有人可以告訴我做錯了什么嗎?
好吧,我已經下載了該組件並按照您的方式進行了操作
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (TextBox1.Text.Length < 3 Or TextBox1.Text.IndexOf(":") < 1) Then
MsgBox("Please type value in format like {email:password}")
Return
End If
' Get the values and parse it
Dim sources As String() = TextBox1.Text.Split(":")
' Now, we try to set it to page
' pay attention at `document.querySelector('#id')` it should be ID of the element
WebControl1.ExecuteJavascript(String.Format("document.querySelector('#email').value = '{0}'", sources(0)))
WebControl1.ExecuteJavascript(String.Format("document.querySelector('#password').value = '{0}'", sources(1)))
End Sub
這是我的登錄頁面代碼(WebControl組件中加載的頁面)
<body>
<input type="email" id="email" />
<input type="password" id="password" />
<button id="loginButton">Login</button>
</body>
一切似乎都正常
您可以運行我的示例:將文本框,webcontrol和按鈕放在表單上,將WebControl1.Source設置為“ http://cafe-ht.ml/fake/fake-login.html ”,然后單擊按鈕復制處理程序
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.