| 代码说明:可以使用TextBox空间的Text属性来对文本框设置一个值或是读取用户输入到文本框的值。
下面的程序演示,当页面第一次加载时,Country文本框被设置了默认值"United States".
如何为文本框设置一个包含引号的字符串呢?,要对Text属性设置包含引号的字符欻国内,需要使用双引号来实现:
Comments.Text="He said ""Good Morning!""
<Script Runat="Server">
Sub Page_Load( s As Object, e As EventArgs )
If Not IsPostBack Then
txtCountry.Text = "United States"
End If
End Sub
</Script>
<html>
<head><title>TextBoxText.aspx</title></head>
<body>
<form Runat="Server">
Please enter the name of your country:
<br>
<asp:TextBox
id="txtCountry"
Runat="Server"/>
<asp:Button
Text="Submit!"
Runat="Server"/>
</form>
</body>
</html>
|