⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asp_radiobutton.aspx

📁 东软内部材料(四)asp等相关的教学案例 
💻 ASPX
字号:
<%@Page Language="C#"%>
<%@Import Namespace="System.Drawing" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>

<script language="JScript">
<!--
function ShowHTMLContent() {
  var strURL = 'http://<% = Request.ServerVariables["SERVER_NAME"] %><% = Request.Path %>?<% = Request.QueryString %>';
  var strDisplay = new String;
  var objHTTP = new ActiveXObject("microsoft.XMLHTTP")
  objHTTP.open('GET', strURL, false);
  objHTTP.send();
  var strReply = objHTTP.responseText;
  var intStart = strReply.indexOf('<!' + '--start-->') + 12;
  var intEnd = strReply.indexOf('<!' + '--end-->');
  if ((intStart > 0) && (intEnd > intStart))
    var strDisplay = strReply.substring(intStart, intEnd);
  document.all['outHTML'].innerText = strDisplay + ' ';
}
function SetCheck(strCheckboxName) {
  document.all[strCheckboxName].checked = true;
}
//-->
</script>

<!-- #include file="style.inc" -->
</head>
<body bgcolor="#ffffff" onload="ShowHTMLContent()">
<!--------------------------------------------------------------------------->
<span class="heading">ASP:RadioButton Control</span> &nbsp; &nbsp; &nbsp;
<form runat="server" method="get">

<!--start-->
<ASP:RadioButton id="MyControl" Text="My RadioButton" runat="server" />
<!--end-->

<p />
<div id="outError" runat="server" />
<font face="Courier New" size="2"><div style="background-color:gainsboro; padding-left:10px" id="outHTML">Fetching HTML content...</div></font>

<table border="0">
<tr><td nowrap="nowrap"><input type="checkbox" id="chkAccessKey" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">AccessKey =</td><td nowrap="nowrap"><input type="text" size="1" id="txtAccessKey" runat="server" onkeypress="SetCheck('chkAccessKey')" /></td>
<td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;</td>
<td nowrap="nowrap"><input type="checkbox" id="chkAutoPostBack" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">AutoPostBack =</td><td nowrap="nowrap"><select id="selAutoPostBack" size="1" runat="server" onchange="SetCheck('chkAutoPostBack')"><option>True</option><option>False</option></select></td></tr>
<tr><td nowrap="nowrap"><input type="checkbox" id="chkBackColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BackColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtBackColor" runat="server" onkeypress="SetCheck('chkBackColor')" /></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtBorderColor" runat="server" onkeypress="SetCheck('chkBorderColor')" /></td></tr>
<tr><td nowrap="nowrap"><input type="checkbox" id="chkBorderStyle" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderStyle =</td><td nowrap="nowrap"><select id="selBorderStyle" size="1" runat="server" onchange="SetCheck('chkBorderStyle')">
<option value="4">BorderStyle.Solid</option><option value="3">BorderStyle.Dashed</option><option value="2">BorderStyle.Dotted</option><option value="5">BorderStyle.Double</option>
<option value="6">BorderStyle.Groove</option><option value="8">BorderStyle.Inset</option><option value="1">BorderStyle.None</option><option value="0">BorderStyle.NotSet</option>
<option value="9">BorderStyle.Outset</option><option value="7">BorderStyle.Ridge</option></select></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderWidth" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderWidth =</td><td nowrap="nowrap"><input type="text" size="2" id="txtBorderWidth" runat="server" onkeypress="SetCheck('chkBorderWidth')" />px</td></tr>
<tr><td nowrap="nowrap"><input type="checkbox" id="chkChecked" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Checked =</td><td nowrap="nowrap"><select id="selChecked" size="1" runat="server" onchange="SetCheck('chkChecked')"><option>True</option><option>False</option></select></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkEnabled" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Enabled =</td><td nowrap="nowrap"><select id="selEnabled" size="1" runat="server" onchange="SetCheck('chkEnabled')"><option>True</option><option>False</option></select></td></tr>
<tr><td nowrap="nowrap"><input type="checkbox" id="chkForeColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">ForeColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtForeColor" runat="server" onkeypress="SetCheck('chkForeColor')" /></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkGroupName" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">GroupName =</td><td nowrap="nowrap"><input type="text" size="15" id="txtGroupName" runat="server" onkeypress="SetCheck('chkGroupName')" /></td></tr>
<tr><td nowrap="nowrap"><input type="checkbox" id="chkHeight" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Height =</td><td nowrap="nowrap"><input type="text" size="2" id="txtHeight" runat="server" onkeypress="SetCheck('chkHeight')" />px</td><td nowrap="nowrap"></td>
<td nowrap="nowrap"></td><td align="right" nowrap="nowrap">ID =</td><td nowrap="nowrap"><% = MyControl.ID %></td></tr>
<tr><td nowrap="nowrap"><input type="checkbox" id="chkText" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Text =</td><td nowrap="nowrap"><input type="text" size="20" id="txtText" runat="server"  onkeypress="SetCheck('chkText')"/></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkTextAlign" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">TextAlign =</td><td nowrap="nowrap"><select id="selTextAlign" size="1" runat="server" onchange="SetCheck('chkTextAlign')">
<option value="1">TextAlign.Left</option><option value="2">TextAlign.Right</option></select></td></tr>
<tr><td nowrap="nowrap"><input type="checkbox" id="chkToolTip" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">ToolTip =</td><td nowrap="nowrap"><input type="text" size="20" id="txtToolTip" runat="server"  onkeypress="SetCheck('chkToolTip')"/></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkVisible" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Visible =</td><td nowrap="nowrap"><select id="selVisible" size="1" runat="server" onchange="SetCheck('chkVisible')"><option>True</option><option>False</option></select></td></tr>
<tr><td nowrap="nowrap"><input type="checkbox" id="chkWidth" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Width =</td><td nowrap="nowrap"><input type="text" size="2" id="txtWidth" runat="server" onkeypress="SetCheck('chkWidth')" />px</td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="button" Value="Reset" onclick="javascript:location.href='http://<% = Request.ServerVariables["SERVER_NAME"] %><% = Request.Path %>'"></td><td nowrap="nowrap"></td><td nowrap="nowrap"><input type="submit" Value="Update" runat="server" /></td></tr>
</table>
</form>

<script language="C#" runat="server">

	void Page_Load(Object sender, EventArgs e)
	{
		outError.InnerHtml = "";

		try
		{
			if (IsPostBack)
			{
				if (chkAccessKey.Checked) MyControl.AccessKey = txtAccessKey.Value;
				if (chkAutoPostBack.Checked) MyControl.AutoPostBack = Convert.ToBoolean(selAutoPostBack.Value);
				if (chkBackColor.Checked) MyControl.BackColor = Color.FromName(txtBackColor.Value);
				if (chkBorderColor.Checked) MyControl.BorderColor = Color.FromName(txtBorderColor.Value);
				if (chkBorderStyle.Checked) MyControl.BorderStyle = (BorderStyle)Convert.ToInt32(selBorderStyle.Value);
				if (chkBorderWidth.Checked) MyControl.BorderWidth = Unit.Pixel(Convert.ToInt32(txtBorderWidth.Value));
				if (chkChecked.Checked) MyControl.Checked = Convert.ToBoolean(selChecked.Value);
				if (chkEnabled.Checked) MyControl.Enabled = Convert.ToBoolean(selEnabled.Value);
				if (chkForeColor.Checked) MyControl.ForeColor = Color.FromName(txtForeColor.Value);
				if (chkGroupName.Checked) MyControl.GroupName = txtGroupName.Value;
				if (chkHeight.Checked) MyControl.Height = Unit.Pixel(Convert.ToInt32(txtHeight.Value));
				if (chkText.Checked) MyControl.Text = txtText.Value;
				if (chkTextAlign.Checked) MyControl.TextAlign = (TextAlign)Convert.ToInt32(selTextAlign.Value);
				if (chkToolTip.Checked) MyControl.ToolTip = txtToolTip.Value;
				if (chkVisible.Checked) MyControl.Visible = Convert.ToBoolean(selVisible.Value);
				if (chkWidth.Checked) MyControl.Width = Unit.Pixel(Convert.ToInt32(txtWidth.Value));
			}

			txtAccessKey.Value = MyControl.AccessKey;
			selAutoPostBack.Value = MyControl.AutoPostBack.ToString();
			txtBackColor.Value = MyControl.BackColor.Name;
			txtBorderColor.Value = MyControl.BorderColor.Name;
			selBorderStyle.Value = MyControl.BorderStyle.ToString();
			txtBorderWidth.Value = MyControl.BorderWidth.Value.ToString();
			selChecked.Value = MyControl.Checked.ToString();
			selEnabled.Value = MyControl.Enabled.ToString();
			txtForeColor.Value = MyControl.ForeColor.Name;
			txtGroupName.Value = MyControl.GroupName;
			txtHeight.Value = MyControl.Height.Value.ToString();
			txtText.Value = MyControl.Text;
			selTextAlign.Value = MyControl.TextAlign.ToString();
			txtToolTip.Value = MyControl.ToolTip;
			selVisible.Value = MyControl.Visible.ToString();
			txtWidth.Value = MyControl.Width.Value.ToString();
		}
		catch (Exception objError)
		{
			outError.InnerHtml = "<b>* Error</b>: " + objError.Message + "<p />";
		}
	}

</script>

<!--------------------------------------------------------------------------->
<!-- #include file="foot.inc" -->
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -