It is now 442010 52416 pm the and marks work just as

Info icon This preview shows pages 805–807. Sign up to view the full content.

View Full Document Right Arrow Icon
Hello World! It is now 4/4/2010 5:24:16 PM The <% and %> marks work just as they did in classic ASP, indicating that code falls between them (in this case, C#). The = sign immediately following the opening tag causes ASP.NET to evaluate the expression inside the tags and display the value. Run the page by pressing F5. Adding Controls You can add server-side controls to a web form in three ways: by writing markup in the .aspx page, by dragging controls from the toolbox (to either the Source or Design view), or by writing code that adds them at runtime. For example, suppose you want to use radio buttons to let the user choose one of three shipping companies when placing an order. You can write the following HTML into the <form> element in the HTML window: <asp:RadioButton GroupName="Shipper" id="Speedy" text="Speedy Express" Checked="True" runat="server"> </asp:RadioButton> <asp:RadioButton GroupName="Shipper" id="United" text="United Package" runat="server"> </asp:RadioButton> <asp:RadioButton GroupName="Shipper" id="Federal" text="Federal Shipping" runat="server"> </asp:RadioButton> The asp tags declare server-side ASP.NET controls that are replaced with normal HTML when the server processes the page. When you run the application, the browser displays three radio buttons in a button group; selecting one deselects the others. You can create the same effect more easily by dragging three buttons from the Visual Studio toolbox onto the form, or to make life even easier, you can drag a radio button list onto the form, which will manage a set of radio buttons as a group. When you select a radio button list control in the Design view, a smart tag appears, prompting you to choose a data source (which allows you to bind to a collection; perhaps one you’ve obtained from a database) or to edit items. Clicking Edit Items opens the ListItem Collection Editor, where you can add three radio buttons. Creating a Web Application | 781
Image of page 805

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Each radio button is given the default name ListItem, but you may edit its text and value in the ListItem properties, where you can also decide which of the radio buttons is selected, as shown in Figure 21-1 . Figure 21-1. List item collection You can improve the look of your radio button list by changing properties in the Prop- erties window, including the font, colors, number of columns, repeat direction (vertical is the default), and so forth, as well as by utilizing Visual Studio’s extensive support for CSS styling, as shown in Figure 21-2 . In Figure 21-2 , you can just see that in the lower-righthand corner you can switch between the Properties window and the Styles window. Here, we’ve used the Properties window to set the tool tip, and the Styles window to create and apply the ListBox style, which creates the border around our listbox and sets the font and font color. We’re also using the split screen option to look at Design and Source at the same time.
Image of page 806
Image of page 807
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern