QA


Q&A

Q1:

If I use a DropDownList or series of RadioButton Web controls to let the user choose one option from, say, 50 legal choices, does this mean I have to enter in all 50 choices by hand?

A1:

With what you know now, the answer is yes. In Hour 17, "Working with Data-Bound DropDownLists, RadioButtons, and CheckBoxes," we will examine how to populate the DropDownList Web control with data from a database. Furthermore, we will see how to create a series of radio buttons or check boxes from database data using the RadioButtonList and CheckBoxList Web control.

Q2:

I have created a DropDownList with 10 list items on an ASP.NET web page. Now, I want to provide this exact same DropDownList Web control on a different ASP.NET web page. Obviously, I can accomplish this by creating a new DropDownList web control on the second page and reentering the 10 options by hand. Is there any easier or quicker way?

A2:

If you want to copy a DropDownList Web control and all of its list items from one ASP.NET web page to another, start by loading up both ASP.NET web pages. On the ASP.NET page that contains the DropDownList Web control, go to the Source view and find the DropDownList Web control in the ASP.NET page's HTML section. This will contain Web control markup like

<asp:DropDownList docEmphasis">DropDownListID" runat="server">     <asp:ListItem Value="Value1">Text1</asp:ListItem>     <asp:ListItem Value="Value2">Text2</asp:ListItem>     ...     <asp:ListItem Value="ValueN">TextN</asp:ListItem> </asp:DropDownList> 


Note that for each list item in the DropDownList, there will be an <asp:ListItem>. Copy all of the DropDownList Web control syntax and then paste it into the Source view of the ASP.NET page that you want to add the same DropDownList to.

Using this technique, you will not have to reenter all of the DropDownList options by hand in the second ASP.NET page.

Q3:

When I'm displaying a series of radio buttons, none of the radio buttons are selected by default. This means that a user can simply not pick one of the options. What if I want to require that a user select one of the radio buttons?

A3:

When a radio button in a group of radio buttons is selected, the end user cannot unselect a choice. However, when a user first visits a page, none of the radio buttons are selected. This means a user can simply not choose one of the options in the group by virtue of not clicking on any radio button in the group.

Typically, you want the user to have to select one of the options. To accomplish this, you need to have one of the radio buttons in the group selected by default. To accomplish this, in Visual Web Developer, click on the RadioButton Web control that you want selected by default. This will load its properties in the Properties window. From there, set the RadioButton control's Checked property to true.

Keep in mind that only one of the radio buttons in the group can be selected by default. If you set the Checked property to true for multiple RadioButton Web controls in the group, the user's browser will select only one such radio button.




Sams Teach Yourself ASP. NET 2.0 in 24 Hours, Complete Starter Kit
Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ISBN: 0672327384
EAN: 2147483647
Year: 2004
Pages: 233

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