如何将输入值传递给后面的代码?

How to pass the input value to the code behind?

我正在使用 asp 文本框,但不知何故它不能在苹果设备上聚焦,所以我尝试在 html 中输入标签,它起作用了。但是现在我需要将值传递给后面(vb 脚本)我尝试了请求。form/request.querystring,其中 none 有效。

这是给vb传值的代码,但是无法聚焦: ASPX:

<asp:TextBox ID="txtUserID" runat="server" AutoPostBack="false" Height="100"        Font-Size="50"/>
<a href="javascript: PressEnterViaNextButton();"/>

JS:

document.getElementById("txtUserID").focus();

VB:

Private Sub txtUserID_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtUserID.TextChanged
        Session("UserID") = txtUserID.Text
    End Sub

这是可以关注的代码,但是不知道怎么传值。

ASPX:

<input runat="server" id="txtUserID" name="txtUserID1" type="text" class="input"  onchange="getValue(this.value)" value="1"/>
                    <a href="javascript: PressEnterViaNextButton();"/>

VB:

Dim userid As String = Request.Form("txtUserID")

如果您正在使用 HTML 输入并希望在服务器端代码中获取文本框的值,那么您将从 Page_Load 事件中的查询字符串集合中读取文本框的值.

HTML CODE
'
<input type="text" id="txtUserid" name="txtUserid" value="1" />
<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" />
<p>
  My User Id: <%=Session("MyUserId")%>
</p>


SERVER-SIDE CODE
'
Protected Sub Page_Load(sender As Object, e As System.EventArgs)
'
' Submit button was pressed
If Request("btnSubmit") = "Submit" Then
    Session("MyUserId") = Request("txtUserId")
End If
'
End Sub

按下提交按钮后,

标记现在将包含来自文本框的数据。