![]() |
|
| <form action="intro4_vb.aspx" method="post" runat=server> <h3> Name: <asp:textbox id="Name" runat="server"/> Category: <asp:dropdownlist id="Category" runat=server> <asp:listitem >psychology</asp:listitem> <asp:listitem >business</asp:listitem> <asp:listitem >popular_comp</asp:listitem> </asp:dropdownlist> </h3> <asp:button text="Lookup" runat="server"/> </form> |
| <form action="intro5_vb.aspx" method="post" runat="server"> <asp:adrotator AdvertisementFile="ads.xml" BorderColor="black" BorderWidth=1 runat="server"/> <h3> Name: <asp:textbox id="Name" runat="server"/> Category: <asp:dropdownlist id="Category" runat=server> <asp:listitem >psychology</asp:listitem> <asp:listitem >business</asp:listitem> <asp:listitem >popular_comp</asp:listitem> </asp:dropdownlist> </h3> <asp:button text="Lookup" runat="server"/> </form> |
| <html> <head> <link rel="stylesheet"href="intro.css"> </head> <script language="VB" runat=server> Sub SubmitBtn_Click(Sender As Object, E As EventArgs) Message.Text = "Hi " & HttpUtility.HtmlEncode(Name.Text) & ", you selected: " & Category.SelectedItem.Text End Sub </script> <body> <center> <form action="intro6_vb.aspx" method="post" runat="server"> <asp:adrotator AdvertisementFile="ads.xml" BorderColor="black" BorderWidth=1 runat="server"/> <h3> Name: <asp:textbox id="Name" runat="server"/> Category: <asp:dropdownlist id="Category" runat=server> <asp:listitem >psychology</asp:listitem> <asp:listitem >business</asp:listitem> <asp:listitem >popular_comp</asp:listitem> </asp:dropdownlist> </h3> <asp:button text="Lookup" OnClick="SubmitBtn_Click" runat="server"/> <p> <asp:label id="Message" runat="server"/> </form> </center> </body> </html> |
| <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> |
| <html> <script language="VB" runat="server"> Sub Page_Load(Sender As Object, E As EventArgs) Dim RandomGenerator As Random RandomGenerator = New Random(DateTime.Now.Millisecond) Dim RandomNum As Integer RandomNum = RandomGenerator.Next(0, 3) Select RandomNum Case 0: Name.Text = "Scott" Case 1: Name.Text = "Fred" Case 2: Name.Text = "Adam" End Select AnchorLink.NavigateUrl = "controls_navigationtarget_vb.aspx?name=" & System.Web.HttpUtility.UrlEncode(Name.Text) End Sub </script> <body> <h3><font face="Verdana">Performing Page Navigation (Scenario 1)</font></h3> <p> This sample demonstrates how to generate a HTML Anchor tag that will cause the client to navigate to a new page when he/she clicks it within the browser. <p> <hr> <p> <asp:hyperlink id="AnchorLink" font-size=24 runat=server> Hi <asp:label id="Name" runat=server/> please click this link! </asp:hyperlink> </body> </html> |
| <html> <script language="VB" runat="server"> Sub EnterBtn_Click(Sender As Object, E As EventArgs) If Not (Name.Text = "") Response.Redirect("Controls_NavigationTarget_vb.aspx?name=" & System.Web.HttpUtility.UrlEncode(Name.Text)) Else Message.Text = "Hey! Please enter your name in the textbox!" End If End Sub </script> <body> <h3><font face="Verdana">Performing Page Navigation (Scenario 2)</font></h3> <p> This sample demonstrates how to navigate to a new page from within a <asp:button> click event, passing a <asp:textbox> value as a querystring argument (validating first that the a legal textbox value has been specified). <p> <hr> <form action="controls6.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" forecolor="red" font-bold="true" runat=server/> </font> </form> </body> </html> |