ASlP

3
Web Control: The Radio Button List Radio Button List Fundamentals Introduction To assist you with creating a group of radio buttons, you can use the RadioButtonList control. This control is implemented by the RadioButtonList class defined in the System.Web.UI.WebControls namespace of the System.Web.dll assembly. Creating a Radio Button List To visually create a radio button list, from the Standard section of the Toolbox, you can drag RadioButtonList and drop it on the form. You would be asked to create each item of the group. To do this, you can click its arrow button and click Edit Items, then use the ListItem Collection Editor: If the radio button list was already created, to access the ListItem Collection Editor, click the radio button list on the form. In the Properties window, click Items and click browse button. To manually create a group of radio buttons, create an <asp:RadioButtonList> tag on the form: <%@ Page Language="C#" %> <html> <head> <title>Exercise</title> </head> <body> <h3>Exercise</h3> <form id="frmRealEstate" method="post" runat="server"> <asp:RadioButtonList id="Genders" runat="server"></asp:RadioButtonList> </form> </body> </html> To create each item of the group, If you are using the ListItem Collection Editor, click Add If you are working manually, between the opening and the closing tags, create an asp:ListItem tag with its own starting and closing tags: <%@ Page Language="C#" %> <html> <head> <title>Exercise</title> </head>

description

fg

Transcript of ASlP

  • 7/4/2015 ASP.NETWebControl:TheRadioButtonList

    http://www.csharpkey.com/aspnet/controls/radiobuttonlist.htm 1/3

    WebControl:TheRadioButtonListRadioButtonListFundamentalsIntroductionToassistyouwithcreatingagroupofradiobuttons,youcanusetheRadioButtonListcontrol.This control is implemented by the RadioButtonList class defined in theSystem.Web.UI.WebControlsnamespaceoftheSystem.Web.dllassembly.

    CreatingaRadioButtonListTovisuallycreatearadiobuttonlist,fromtheStandardsectionoftheToolbox,youcandragRadioButtonListanddropitontheform.Youwouldbeaskedtocreateeachitemofthegroup.Todothis,youcanclickitsarrowbuttonandclickEditItems,thenusetheListItemCollectionEditor:

    Iftheradiobuttonlistwasalreadycreated,toaccesstheListItemCollectionEditor,clicktheradiobuttonlistontheform.InthePropertieswindow,clickItemsandclickbrowsebutton.

    Tomanuallycreateagroupofradiobuttons,createantagontheform:

    Exercise

    Exercise

    Tocreateeachitemofthegroup,

    IfyouareusingtheListItemCollectionEditor,clickAddIfyouareworkingmanually,betweentheopeningandtheclosingtags,createanasp:ListItemtagwithitsownstartingandclosingtags:

    Exercise

  • 7/4/2015 ASP.NETWebControl:TheRadioButtonList

    http://www.csharpkey.com/aspnet/controls/radiobuttonlist.htm 2/3

    CharacteristicsofaRadioButtonListTheCaptionsofRadioButtonsObviouseachradiobuttonshoulddisplaytexttoshowwhatitisusedfor:

    IfyouareworkingintheListItemCollectionEditor,ontheleftside,clickanitem.Ontherightside,clickTextandtypethedesiredstringIfyouareworkingmanually,tospecifythecaptionofaradiobutton,typeitsstringbetweenthebeginningandtheendingtags

    Hereareexamples:

    Exercise

    MaleFemaleUnknown

    Thiswouldproduce:

    TheCaptionAlignmentofaRadioButtonBydefault, the captions of the radiobuttons arepositionedon the right side of their roundboxes. This characteristic is controlled by the TextAlign attribute of the RadioButtonListcontrolandwhosedefaultvalueisRight.Ifyouwantthecaptionstobepositionedtotheleft,assigntheLeftstringtothisattribute.Hereisanexample:

    Exercise

  • 7/4/2015 ASP.NETWebControl:TheRadioButtonList

    http://www.csharpkey.com/aspnet/controls/radiobuttonlist.htm 3/3

    MaleFemaleUnknown

    Thiswouldproduce:

    Home Copyright20092011C#Key