我正在尝试对此进行编码,但我发现很难解决它。我只是向您展示场景的图像。
html代码:
<tr>
<td>Lat</td>
<td><input type="text" size="20" id="dd_lat" value="38.898556" runat="server"></td>
</tr>
<tr>
<td>Long</td>
<td><input type="text" size="20" id="dd_long" value="-77.037852" runat="server"></td>
</tr>
VB.NET代码
Private Sub Button1_ApplyCoordinates_Click(sender As Object, e As EventArgs) Handles Button1_ApplyCoordinates.Click
Mapping.TextBox2_Latitude.Text = WebBrowser1.Document.GetElementById("dd_lat").ToString
Mapping.TextBox1_Longhitude.Text = WebBrowser1.Document.GetElementById("dd_long").ToString
End Sub
答案 0 :(得分:1)
ToString
方法只是返回GetElementById
返回的对象类型,而不是HTML中输入的值。要获得纬度或其他任何内容,请使用GetAttribute
方法并传入&#34; value&#34;。因此,您的Sub
可以编码为:
Private Sub Button1_ApplyCoordinates_Click(sender As Object, e As EventArgs) Handles Button1_ApplyCoordinates.Click
Mapping.TextBox2_Latitude.Text = WebBrowser1.Document.GetElementById("dd_lat").GetAttribute("value")
Mapping.TextBox1_Longhitude.Text = WebBrowser1.Document.GetElementById("dd_long").GetAttribute("value")
End Sub