中国搜 程序源代码学习 编程源代码 直接应用在编程实践中 优秀编程书籍源码欣赏

收藏本页到>> 新浪ViVi  365Key网摘   IE收藏夹 |设为首页

 中国搜首页 >>ASP.NET相关>>把文本赋值给文本框 C#版

代码说明:可以使用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>

   运行演示程序   

  ©2004   www.zhonguosou.com