ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: ASP.NET :: ASP.NET - °´Å¥¿Ø¼þ

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

ASP.NET
asp.netµÄ°²×°
ASP ºÍ ASP.NET Ö..
ASP.NET ½éÉÜ

ASP.NET - °´Å¥¿Ø¼þ


×÷Õß:w3schools ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-08-06 ä¯ÀÀ:3467 :: ::

The Button control is used to display a push button.
°´Å¥¿Ø¼þ¿ÉÓÃÀ´ÏÔʾ°´Å¥¡£


The Button Control
°´Å¥¿Ø¼þ

The Button control is used to display a push button. The push button may be a submit button or a command button. By default, this control is a submit button.
°´Å¥¿Ø¼þ¿ÉÓÃÀ´ÏÔʾ°´Å¥¡£°´Å¥¿ÉÒÔÊÇÌá½»°´Å¥»òÊÇÒ»¸öÃüÁî°´Å¥¡£Ä¬ÈÏÇé¿öÏÂÕâ¸ö¿Ø¼þÊÇÒ»¸öÌá½»°´Å¥¡£

A submit button does not have a command name and it posts the page back to the server when it is clicked. It is possible to write an event handler to control the actions performed when the submit button is clicked.
Ìá½»°´Å¥²»ÐèÒªÃüÁîÃû³Æ²¢ÇÒµ±Ëüµã»÷ʱ»á½«Ìá½»µÄÒ³Ãæ·µ»Øµ½·þÎñÆ÷¡£µ±Ìá½»°´Å¥µã»÷ʱ¿ÉÒÔдʼþ´¦ÀíÆ÷À´¿ØÖÆÐж¯µÄÖ´ÐС£

A command button has a command name and allows you to create multiple Button controls on a page. It is possible to write an event handler to control the actions performed when the command button is clicked.
ÃüÁî°´Å¥ÐèÒªÓÐÃüÁîµÄÃû³Æ²¢ÇÒ¿ÉÒÔÔÚÒ»ÕÅÒ³ÃæÉϽ¨Á¢¶à¸ö°´Å¥¿Ø¼þ¡£µ±ÃüÁî°´Å¥°´ÏÂʱ¿ÉÒÔдʼþ´¦ÀíÆ÷À´¿ØÖÆÐж¯µÄÖ´ÐС£

The Button control's attributes and properties are listed in our web controls reference page.
Óйذ´Å¥¿Ø¼þµÄËùÓÐÊôÐÔ¶¼ÂÞÁÐÔÚÎÒÃǵÄWEB¿Ø¼þ²Î¿¼Ò³ÉÏÁË

The example below demonstrates a simple Button control:
ÏÂÃæµÄ¾ÙÀýÑÝʾÁ˼òµ¥µÄ°´Å¥¿Ø¼þ£º

<html>
<body>

<form runat="server">
<asp:Button id="b1" Text="Submit" runat="server" />
</form>
</body>
</html>

 


Add a Script
Ìí¼Ó½Å±¾

A form is most often submitted by clicking on a button.
±íµ¥Í¨³£ÊÇͨ¹ýµã»÷°´Å¥À´½øÐÐÌá½»µÄ¡£

In the following example we declare one TextBox control, one Button control, and one Label control in an .aspx file. When the submit button is triggered, the submit subroutine is executed. The submit subroutine writes a text to the Label control:
ÔÚÏÂÃæµÄ¾ÙÀýÖÐÎÒÃǽ«ÔÚÒ»¸ö.aspxÎļþÖÐÉùÃ÷Ò»¸öÎı¾¿ò¿Ø¼þ£¬Ò»¸ö°´Å¥¿Ø¼þÒÔ¼°Ò»¸ö±êÇ©¿Ø¼þ¡£µ±Ìá½»°´Å¥±»´¥·¢£¬Ìá½»×Ó³ÌÐò½«±»Ö´ÐС£Ìá½»×Ó³ÌÐò»áÔÚ±êÇ©¿Ø¼þÉÏдһЩÎÄ×Ö£º

<script runat="server">
Sub submit(sender As Object, e As EventArgs)
lbl1.Text="Your name is " & txt1.Text
End Sub
</script>
<html>
<body>
<form runat="server">
Enter your name:
<asp:TextBox id="txt1" runat="server" />
<asp:Button OnClick="submit" Text="Submit" runat="server" />
<p><asp:Label id="lbl1" runat="server" /></p>
</form>
</body>
</html>

Example£¨¾ÙÀý£©

ÆÀÂÛ (0) All