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

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

 中国搜首页 >>ASP.NET相关>>RadioButton的AutoPostBack属性 C#版

代码说明:RadioButton按钮支持AutoPostBack属性,当RadioButton被允许AutoPostBack属性时,只有一个新的按钮被选定,那么包含该按钮的表单就被自动提交。
    下面的程序清单 根据用户的所选的单选按钮显示不同的背景颜色。注意该页面并不包括一个提交按钮。因为每个按钮的AutoPostBack属性都为True。只要用户一选择,表单便自动提交。

<Script Runat="Server">
Dim strBackGroundColor As String = "white"
Sub BackColor_Changed( s As Object, e As EventArgs )
strBackGroundColor = s.Text
End Sub
</Script>
<html>
<head><title>RadioButtonAutoPostBack.aspx</title></head>
<body bgcolor="<%= strBackGroundColor %>">
<form Runat="Server">
Select a background color:<p>
<asp:RadioButton
ID="radRed"
AutoPostBack="True"
GroupName="backcolor"
OnCheckedChanged="BackColor_Changed"
Text="Red"
Runat="Server" /><br>
<asp:RadioButton
ID="radBlue"
AutoPostBack="True"
GroupName="backcolor"
OnCheckedChanged="BackColor_Changed"
Text="Blue"
Runat="Server" /><br>
<asp:RadioButton
ID="radGreen"
AutoPostBack="True"
GroupName="backcolor"
OnCheckedChanged="BackColor_Changed"
Text="Green"
Runat="Server" />
</form>
</body>
</html>

   运行演示程序   

  ©2004   www.zhonguosou.com