This code retrieves the selected value of the RadioButton group and writes it to the page.
Note that you can also use individual RadioButton controls to create a group of RadioButtons, but in that case, you will need to use the GroupName property to ensure that only one RadioButton can be selected at a time.
Here is an example of using individual RadioButtons:
In this case, the GroupName property is set to "programmingLanguages" to ensure that only one RadioButton can be selected at a time.
Radio button in ASP.NET in Hindi
ASP.NET mein, RadioButton ek web control hota hai jisse ek se zyada options ke beech mein se ek option select kiya ja sakta hai. RadioButton ka use forms mein input lene ke liye, jaise ki "Yes/No", "Male/Female", "Agree/Disagree" etc, ki tarah ki situations mein kiya jaata hai.
Yahan ek example diya ja raha hai jisme RadioButton control ka use kiya gaya hai:
Is example mein, 3 RadioButtons diye gaye hai jo ek group mein hain. Har RadioButton control ka unique ID hota hai, jisse code-behind se unhe identify kiya ja sakta hai. GroupName property ke through, ye RadioButton controls ko ek group mein organize kiya gaya hai.
RadioButton ka value code-behind mein retrieve karne ke liye, "SelectedValue" property ka use kiya jaata hai. Yahan ek example diya ja raha hai, jisme RadioButton ka value retrieve karne ke baad uska message display kiya ja raha hai:
Is code-behind example mein, "Request.Form" property se selected RadioButton ka value retrieve kiya ja raha hai. Agar koi RadioButton select nahi kiya gaya hai, toh "Please select a color" message display kiya jaayega.