Let us see some of the important properties of Radio button control Important Properties of a Radio Button Control: There are two different syntaxes for Radio Button Control one is for RadioButton control and the other one is for RadioButtonList. Otherwise, it will show an error when we try to use it. NOTE: We can use these two OrderedList and UnorderedList only when the layout is set to vertical. OrderedList: It will show the numbers instead of a bullet in the radio buttons.the radio button will have bullets in front of radio buttons. UnorderedList: It shows with the bullet points it will only support the vertical layout.Flow: If we select the Flow, it will not take the table for the radio will display the radio buttons as it is.Table: If we select the table then the output of radio buttons will come in table format.Let’s have a look at what these four values meant for and how it is used. It takes the four values namely Table, flow, tableorderedlist, unorderedlist. RepeatLayout: It is used to determine the radio button in an HTML table. By default, the direction is set as vertical. RepeatDirection: It is used to decide the direction of the radio buttons, that is whether it should be horizontal or vertical. RepeatColumns: It is used to display the number of columns of the radio button. The layout can be affected by its important property which is supported by RadioButtonList control. As we can see it will take 3 radio buttons as the value of the default has been set to 3.Suppose you want to set the default value as 3, then below is the output for the same. Let’s see if we change this default value how it will look like.Value for the default column by default is Zero and as per the application requirement, we can change this default value.We can see there is a tab for RepeatDirection which will change our layout of radio buttons from Vertical to horizontal manner.RadioButtonList_New.RepeatDirction=RepeatDirection.Horizontal So simply we can change the code as below. Suppose now we want the radio buttons for colors to be in a Horizontal way.Below is the code is given for the different colors for adding the values besides the radio button.RadioButtonList_New contains different values for the colors. So now we want to add values to the radio button.We can arrange it as vertical as well as horizontal manner according to our requirement of the application. RepeatDirection is used for the arrangement of the radio button.Using Property Window, we can add the items in our RadioButtonList via item collection to have the many radio buttons.RadioButtonList_New.RepeatDirection = RepeatDirection.Vertical RadioButtonList_New.RepeatDirection = RepeatDirection.Horizontal If (RadioButtonList_New.RepeatDirection = RepeatDirection.Vertical) Protected void Button2_Click(object sender, EventArgs e) RadioButtonList_New.SelectedValue + " Index =" + Label1.Text = "Below is the selected color Item=" + Protected void Button1_Click(object sender, EventArgs e) Protected void Page_Load(object sender, EventArgs e) Public partial class ListControls : .Page Example of RadioButton in ASP.NETĪSP.NET RadioButton is used to allow the user to pick any one of the multiple options. Let’s have a look at a simple program that has a radio button for selecting the color from the list of various colors. Likewise, we can create many radio buttons as per our requirements and add them to our web page. We can see that our web page is having two radio buttons one is ‘Male’ and the other is ‘Female’. Step 4: Once all these changes have been done we can see the below output. Refer to the above snippet for better understanding.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |