In this walk-through, you will learn about RadioButtonList in detail, and you get answers of the following questions.
- What is RadioButtonList?
- How many Layout types?
- Which Layout is good to use?
- Generate a RadioButtonList with the following:
- List Collection Object C#
- Database Table data
- Manually ListItem
- Working Suggestion with RadioButtonList.
What is RadioButtonList?
RadioButtonList is a Form-Control of Standard section under the Asp.Net WebForms project template. Naming conventions for RadioButtonList is rbl. Using naming conventions helps you find objects on an aspx page very smartly and easily.
RadioButtonList render a group of Radio-Buttons by using data-source, manually added list-item. RadioButtonList allows users to select only one option (Radio -Button) from a list.
RepeatDirection: Set rendering direction on browser. There are two types.
- Horizontal
- Vertical
RepeatLayout: Support the following types of layout.
- Flow: Normal rendering.
- OrderedList: This will display options with 1,2,3,4,5 numbering.
- Table: Under Table layout.
- UnorderedList: This will display a bulleted list •.
- Table: For perfect alignment and view. This will render using HTML tags.
- Flow: It is very lightweight, and Custom CSS can be applied for beautification and alignment as per your current design.
Right Combination of RepeatDirection and RepeatLayout.
SR. NO. | RepeatDirection | RepeatLayout | Remarks |
---|---|---|---|
1 | Horizontal | Flow | Working fine. |
2 | Horizontal | OrderedList | Not Working, Error Message: The UnorderedList and OrderedList layouts only support vertical layout. |
3 | Horizontal | Table | Working fine. |
4 | Horizontal | UnorderedList | Not Working, Error Message: The UnorderedList and OrderedList layouts only support vertical layout. |
5 | Vertical | Flow | Working fine. |
6 | Vertical | OrderedList | Working fine. |
7 | Vertical | Table | Working fine. |
8 | Vertical | UnorderedList | Working fine. |
Generate a RadioButtonList with the following.
ASPX Page Code
C# Code
JavaScript Code
Output

OUTPUT
3. Manually ListItem added to generated RadioButtonList
ASPX Page Code
NO C# Code Wirtten
Javascript Code
OUTPUT
Working Suggestion with RadioButtonList
1. Use CLientIDMode = “Static”. This will not generate a dynamic id of RadioButtonList control. This will help you use id easily in Javascript.
ClientIDMode="Static"
Note: The above settings are recommended for all Form-Controls.
2. Use Javascript for the event and get the selected value of the Radio Button. Try to use Maximum Javascript because this will reduce the server roundtrip and help to run the application faster.
3. For handling server-side events, you have to use the following settings.
- AutoPostBack="true"
- OnSelectedIndexChanged event method.
Happy Coding!
Best ASP.NET Core 9 Hosting Recommendation
At HostForLIFEASP.NET, customers can also experience fast ASP.NET Core hosting. The company invested a lot of money to ensure the best and fastest performance of the datacenters, servers, network and other facilities. Its datacenters are equipped with the top equipments like cooling system, fire detection, high speed Internet connection, and so on. That is why HostForLIFEASP.NET guarantees 99.9% uptime for ASP.NET Core. And the engineers do regular maintenance and monitoring works to assure its Orchard hosting are security and always up.
0 comments:
Post a Comment