扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
<html> <body> <h3><font face="Verdana">Declaring Server Controls</font></h3> This sample demonstrates how to declare the <asp:label> server control and manipulate its properties within a page. <p> <hr> <asp:label id="Message1" font-size="16" font-bold="true" forecolor="red" runat=server>This is Message One</asp:label> <br> <asp:label id="Message2" font-size="20" font-italic="true" forecolor="blue" runat=server>This is Message Two</asp:label> <br> <asp:label id="Message3" font-size="24" font-underline="true" forecolor="green" runat=server>This is Message Three</asp:label> </body> </html> |
<html> <script language="VB" runat="server"> Sub Page_Load(Sender As Object, E As EventArgs) Message.Text = "You last accessed this page at: " & DateTime.Now End Sub </script> <body> <h3><font face="Verdana">Manipulating Server Controls</font></h3> This sample demonstrates how to manipulate the <asp:label> server control within the Page_Load event to output the current time. <p> <hr> <asp:label id="Message" font-size="24" font-bold="true" runat=server/> </body> </html> |
<html> <script language="VB" runat="server"> Sub EnterBtn_Click(Sender As Object, E As EventArgs) Message.Text = "Hi " & Name.Text & ", welcome to ASP.NET!" End Sub </script> <body> <h3><font face="Verdana">Handling Control Action Events</font></h3> <p> This sample demonstrates how to access a <asp:textbox> server control within the "Click" event of a <asp:button>, and use its content to modify the text of a <asp:label>. <p> <hr> <form action="controls3.aspx" runat=server> <font face="Verdana"> Please enter your name: <asp:textbox id="Name" runat=server/> <asp:button text="Enter" Onclick="EnterBtn_Click" runat=server/> <p> <asp:label id="Message" runat=server/> </font> </form> </body> </html> |
<html> <script language="VB" runat="server"> Sub AddBtn_Click(Sender As Object, E As EventArgs) If Not (AvailableFonts.SelectedIndex = -1) InstalledFonts.Items.Add(New ListItem(AvailableFonts.SelectedItem.Value)) AvailableFonts.Items.Remove(AvailableFonts.SelectedItem.Value) End If End Sub Sub AddAllBtn_Click(Sender As Object, E As EventArgs) Do While Not (AvailableFonts.Items.Count = 0) InstalledFonts.Items.Add(New ListItem(AvailableFonts.Items(0).Value)) AvailableFonts.Items.Remove(AvailableFonts.Items(0).Value) Loop End Sub Sub RemoveBtn_Click(Sender As Object, E As EventArgs) If Not (InstalledFonts.SelectedIndex = -1) AvailableFonts.Items.Add(New ListItem(InstalledFonts.SelectedItem.Value)) InstalledFonts.Items.Remove(InstalledFonts.SelectedItem.Value) End If End Sub Sub RemoveAllBtn_Click(Sender As Object, E As EventArgs) Do While Not (InstalledFonts.Items.Count = 0) AvailableFonts.Items.Add(New ListItem(InstalledFonts.Items(0).Value)) InstalledFonts.Items.Remove(InstalledFonts.Items(0).Value) Loop End Sub </script> <body> <h3><font face="Verdana">Handling Multiple Control Action Events</font></h3> <p> This sample demonstrates how to handle multiple control action events raised from different <asp:button> controls. <p> <hr> <form action="controls4.aspx" runat=server> <table> <tr> <td> Available Fonts </td> <td> <!-- Filler --> </td> <td> Installed Fonts </td> </tr> <tr> <td> <asp:listbox id="AvailableFonts" width="100px" runat=server> <asp:listitem>Roman</asp:listitem> <asp:listitem>Arial Black</asp:listitem> <asp:listitem>Garamond</asp:listitem> <asp:listitem>Somona</asp:listitem> <asp:listitem>Symbol</asp:listitem> </asp:listbox> </td> <td> <!-- Filler --> </td> <td> <asp:listbox id="InstalledFonts" width="100px" runat=server> <asp:listitem>Times</asp:listitem> <asp:listitem>Helvetica</asp:listitem> <asp:listitem>Arial</asp:listitem> </asp:listbox> </td> </tr> <tr> <td> <!-- Filler --> </td> <td> <asp:button text="<<" OnClick="RemoveAllBtn_Click" runat=server/> <asp:button text="<" OnClick="RemoveBtn_Click" runat=server/> <asp:button text=">" OnClick="AddBtn_Click" runat=server/> <asp:button text=">>" OnClick="AddAllBtn_Click" runat=server/> </td> <td> <!-- Filler --> </td> </tr> </table> </form> </body> </html> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者