📄 aspnet_forms.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ASP.NET Web Forms</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>ASP.NET Web Forms</h1>
<a href="aspnet_events.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" /></a>
<a href="aspnet_viewstate.asp"><img alt="next" border="0" src="../images/btn_next.gif" /></a>
<hr />
<p class="intro">All server controls must appear within a <form> tag, and the <form> tag must
contain the runat="server" attribute.</p>
<hr />
<h2>ASP.NET Web Forms</h2>
<p>All server controls must appear within a <form> tag, and the <form> tag must
contain the runat="server" attribute. The runat="server" attribute
indicates that the form should be processed on the server. It also indicates
that the enclosed controls can be accessed by server scripts:</p>
<table class="ex" border="1" width="100%">
<tr><td>
<pre><form runat="server"></pre>
<pre>...HTML + server controls</pre>
<pre></form></pre></td></tr>
</table>
<p>
<b>Note:</b> The form is always submitted to the page itself. If you specify an
action attribute, it is ignored. If you omit the method attribute, it will be
set to method="post" by default. Also, if you do not specify the name and id
attributes, they are automatically assigned by ASP.NET.</p>
<p>
<b>Note:</b> An .aspx page can only contain ONE <form runat="server"> control!</p>
<p>
If you select view source in an .aspx page containing a form with no name,
method, action, or id attribute specified, you will see that ASP.NET has added
these attributes to the form. It looks something like this:</p>
<table class="ex" border="1" width="100%">
<tr><td>
<pre><form name="_ctl0" method="post" action="page.aspx" id="_ctl0"></pre>
<pre>...some code</pre>
<pre></form></pre></td></tr>
</table>
<br />
<hr />
<h2>Submitting a Form</h2>
<p>
A form is most often submitted by clicking on a button. The Button server control
in ASP.NET has the
following format:</p>
<table class="ex" border="1" width="100%">
<tr><td>
<pre><asp:Button id="id" text="label" OnClick="sub" runat="server" /></pre>
</td></tr>
</table>
<p>
The id attribute defines a unique name for the button and the text attribute assigns a label
to the button. The onClick
event handler specifies a named subroutine to execute.</p>
<p>In the following example we declare a Button control in an .aspx file. A
button click runs a subroutine which changes the text on the button:</p>
<p><a target="_blank" href="showasp.asp@filename=demo_button">Example</a></p>
<hr />
<a href="aspnet_events.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" /></a>
<a href="aspnet_viewstate.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -