How to assign a text how to know radio button have been selected in ASP.NET?

Question

How to assign a text how to know radio button have been selected in ASP.NET?

Re: How to assign a text how to know radio button have been sele

To assign a text, we need to use the text property and to know whether the radio button have been selected, we need to use the selected property, which returns either true or false.

RadioButton Web Server Control - by Das

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
rd1.Text = "Doctor"
rd2.Text = "Software Engineer"
rd3.Text = "Lawyer"
rd4.Text = "Business Man"
rd5.Text = "Other"
End Sub

Public Sub btnSubmit_OnClick(ByVal sender As Object, ByVal e As EventArgs)
If rd1.Checked Then
lblResult.Text = "So, you are a " & rd1.Text & " (Any surgeries so far?)"
ElseIf rd2.Checked Then
lblResult.Text = "So, you are a " & rd2.Text & " (So you work with Computers, right)"
ElseIf rd3.Checked Then
lblResult.Text = "So, you are a " & rd3.Text & " (How may cases have you attended so far?)"
ElseIf rd4.Checked Then
lblResult.Text = "So, you are a " & rd4.Text & " (Self employeed, huh)"
ElseIf rd5.Checked Then
lblResult.Text = "So, you are a " & rd5.Text & " (What else you are, just curious?)"
Else
lblResult.Text = "OOPS! you selected nothing! Try again."
End If
End Sub

ASP .NET Tutorial: Working with Radio Button Control.