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

📄 html_inputbutton.aspx

📁 东软内部材料(四)asp等相关的教学案例 
💻 ASPX
字号:
<%@Page Language="C#"%>
<!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">HtmlInputButton Controls</span> &nbsp; &nbsp; &nbsp;

<!--start-->
<input id="MySubmit" type="submit" runat="server" />
<input id="MyReset" type="reset" runat="server" />
<input id="MyButton" type="button" runat="server" Value="My Caption" />
<!--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>

<form runat="server" method="get">
<table border="0">
<tr><td colspan="2"><hr /></td><td align="center">- Submit Button -</td><td colspan="4"><hr /></td></tr>
<tr>
<td nowrap="nowrap"><input type="checkbox" id="chkSDisabled" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Disabled =</td><td nowrap="nowrap"><select id="selSDisabled" size="1" runat="server" onchange="SetCheck('chkSDisabled')"><option>True</option><option>False</option></select></td>
<td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;</td>
<td nowrap="nowrap">&nbsp;</td><td align="right" nowrap="nowrap">Name =</td><td nowrap="nowrap"><% = MySubmit.Name %></td><td></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkSValue" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Value =</td><td nowrap="nowrap"><input type="text" size="20" id="txtSValue" runat="server" onkeypress="SetCheck('chkSValue')" /></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkSVisible" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Visible =</td><td nowrap="nowrap"><select id="selSVisible" size="1" runat="server" onchange="SetCheck('chkSVisible')"><option>True</option><option>False</option></select></td>
</tr>
<tr><td colspan="2"><hr /></td><td align="center">- Reset Button -</td><td colspan="4"><hr /></td></tr>
<tr>
<td nowrap="nowrap"><input type="checkbox" id="chkRDisabled" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Disabled =</td><td nowrap="nowrap"><select id="selRDisabled" size="1" runat="server" onchange="SetCheck('chkRDisabled')"><option>True</option><option>False</option></select></td>
<td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;</td>
<td nowrap="nowrap">&nbsp;</td><td align="right" nowrap="nowrap">Name =</td><td nowrap="nowrap"><% = MyReset.Name %></td><td></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkRValue" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Value =</td><td nowrap="nowrap"><input type="text" size="20" id="txtRValue" runat="server" onkeypress="SetCheck('chkRValue')" /></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkRVisible" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Visible =</td><td nowrap="nowrap"><select id="selRVisible" size="1" runat="server" onchange="SetCheck('chkRVisible')"><option>True</option><option>False</option></select></td>
</tr>
<tr><td colspan="2"><hr /></td><td align="center">- Button -</td><td colspan="4"><hr /></td></tr>
<tr>
<td nowrap="nowrap"><input type="checkbox" id="chkBDisabled" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Disabled =</td><td nowrap="nowrap"><select id="selBDisabled" size="1" runat="server" onchange="SetCheck('chkBDisabled')"><option>True</option><option>False</option></select></td>
<td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;</td>
<td nowrap="nowrap">&nbsp;</td><td align="right" nowrap="nowrap">Name =</td><td nowrap="nowrap"><% = MyButton.Name %></td><td></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkBValue" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Value =</td><td nowrap="nowrap"><input type="text" size="20" id="txtBValue" runat="server" onkeypress="SetCheck('chkBValue')" /></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkBVisible" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Visible =</td><td nowrap="nowrap"><select id="selBVisible" size="1" runat="server" onchange="SetCheck('chkBVisible')"><option>True</option><option>False</option></select></td>
</tr><tr>
<td></td><td></td><td></td><td></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 (chkSDisabled.Checked) MySubmit.Disabled = Convert.ToBoolean(selSDisabled.Value);
				if (chkSValue.Checked) MySubmit.Value = txtSValue.Value;
				if (chkSVisible.Checked) MySubmit.Visible = Convert.ToBoolean(selSVisible.Value);
				if (chkRDisabled.Checked) MyReset.Disabled = Convert.ToBoolean(selRDisabled.Value);
				if (chkRValue.Checked) MyReset.Value = txtRValue.Value;
				if (chkRVisible.Checked) MyReset.Visible = Convert.ToBoolean(selRVisible.Value);
				if (chkBDisabled.Checked) MyButton.Disabled = Convert.ToBoolean(selBDisabled.Value);
				if (chkBValue.Checked) MyButton.Value = txtBValue.Value;
				if (chkBVisible.Checked) MyButton.Visible = Convert.ToBoolean(selBVisible.Value);
			}

			selSDisabled.Value = MySubmit.Disabled.ToString();
			txtSValue.Value = MySubmit.Value;
			selSVisible.Value = MySubmit.Visible.ToString();
			selRDisabled.Value = MyReset.Disabled.ToString();
			txtRValue.Value = MyReset.Value;
			selRVisible.Value = MyReset.Visible.ToString();
			selBDisabled.Value = MyButton.Disabled.ToString();
			txtBValue.Value = MyButton.Value;
			selBVisible.Value = MyButton.Visible.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 + -