简体   繁体   English

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

[英]how to pass a value to the code behind asp?

Erm i am new to this.嗯,我是新手。 How do i pass the value the user enters into a text box to the vb code behind?如何将用户在文本框中输入的值传递给后面的 vb 代码?

<input type="text" runat="server" id="amount" name="amount" size="15" />

No need to pass the value As its RunAt = server you can directly access value of the text box using its Text property无需传递值作为其RunAt = server ,您可以使用其Text属性直接访问文本框的值

Example例子

amount.Value 

or you can make use of Request collection to get the value of the textbox Request.Form["amount"]或者您可以使用 Request 集合来获取文本框Request.Form["amount"]的值

Use the ASP.NET-TextBox Control .使用ASP.NET-TextBox 控件

<asp:TextBox ID="TextBox1" runat="server"/>

Then you can access it from codebehind via it's ID然后你可以通过它的 ID 从代码隐藏中访问它

Dim Textbox1Text As String = Me.TextBox1.Text

The Text will automatically persisted in ViewState across postbacks by default.默认情况下,文本将在回发时自动保存在ViewState中。

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

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