Forms

I l @ ve RuBoard

Most of the functions that had to be specifically programmed in traditional ASP are now handled by form controls:

 <%@ Page Language="VB" Trace="False" %> <script runat="server"> Sub Page_Load(Src As Object, E As EventArgs)     If Not Page.IsPostBack Then         won.Items.Add("Yes")         won.Items.Add("No")     Else         Dim resultTxt as String         resultTxt = "Hello, " & first_name.Text & ".  "         if won.SelectedItem.Text = "yes" then             resultTxt += "Congratulations!"         else             resultTxt += "So sorry."         end if         output.Text =  resultTxt     End If End Sub </script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"             "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>Survey</title> </head> <body> <form runat="server" id="form1">     First Name: <asp:Textbox runat="server" id="first_name" /><br />     Have you ever won anything?                   <asp:DropDownList runat="server" id="won" /><br />     <asp:Button runat="server" Text="Submit Answers" /> </form> <asp:Label runat="server" id="output" /> </body> </html> 

Alternatively, the DropDownList could have been written as:

 <asp:DropDownList runat="server" id="won">     <asp:ListItem value="yes" runat="server">Yes</asp:ListItem>     <asp:ListItem value="no" runat="server">No</asp:ListItem> </asp:DropDownList> 

Other form controls include CheckBox , CheckBoxList , ImageButton , ListBox , RadioButton , and RadioButtonList .

I l @ ve RuBoard


Asp. Net. By Example
ASP.NET by Example
ISBN: 0789725622
EAN: 2147483647
Year: 2001
Pages: 154

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net