[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Urgent - Visual Studio Express 2010 and Radio Buttons

Posted on 2011-10-13
6
Medium Priority
?
387 Views
Last Modified: 2012-05-12
Hi folks. I am using ms Visual Studio 2010 Express and have created a a page, test.aspx, that needs to have several radio button. Below is a snippet of one group:
  <tr>
             <td align="right">
                    <asp:Label ID="lblHome" runat="server" Text="Do you own your home?"></asp:Label>
             </td>
             <td >
                   <asp:RadioButton ID="RadHomeYes" runat="server" GroupName="RadHome" Text="Yes" />

                   <asp:RadioButton ID="RadHomeNo" runat="server" GroupName="RadHome" Text="No" />
              </td>
             </tr>

I have a button on the page that executes coding in the test.aspx.vb page that retreives the values of the labels and textboxes. That codign works well.
The PROBLEM is that I can not seem to get the value of the radio button - they aren't required to click on it but I need to know if they did and WHICH one!
Please help as this is urgent.....
0
Comment
Question by:Overthere
  • 3
  • 2
6 Comments
 
LVL 18

Accepted Solution

by:
mgfranz earned 2000 total points
ID: 36965769
This works;

 
Partial Class radio
    Inherits System.Web.UI.Page

    Sub submit(ByVal Sender As Object, ByVal e As EventArgs)
        If RadHomeYes.Checked Then
            Label1.Text = "You selected " & RadHomeYes.Text
        ElseIf RadHomeNo.Checked Then
            Label1.Text = "You selected " & RadHomeNo.Text
        End If
    End Sub
End Class

' radio.aspx page

<body>
    <form id="form1" runat="server">
    <div>
        <asp:RadioButton ID="RadHomeYes" runat="server" GroupName="RadHome" Text="Yes" />
        <br />
        <asp:RadioButton ID="RadHomeNo" runat="server" GroupName="RadHome" Text="No" />
        <br />
        <asp:Button ID="Button1" Text="Submit" OnClick="submit" runat="server" />
        <p>
            <asp:Label ID="Label1" runat="server" /></p>
    </div>
    </form>
</body>

Open in new window

0
 
LVL 2

Expert Comment

by:paulpp
ID: 36965897
Hello,

I copied and pasted your code directly into VS 2010, and all worked fine for me in IE, FireFox, and Chrome.  The only thing I can think of trying is try:

If RadHomeYes.Checked = True Then

Probably wont make a difference, but worth a try.


0
 
LVL 18

Expert Comment

by:mgfranz
ID: 36966927
Umm... paulpp, did you even look at my comment?  I believe that is exactly what I suggested.
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

Author Closing Comment

by:Overthere
ID: 36970187
Thanks! I also tried using the "radiolist" and that worked well too. More questions coming! So stay tuned!
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 36970527
Personally, I don't like to use "radiolist" when there are less than three buttons.  But glad to hear it's working.
0
 
LVL 2

Expert Comment

by:paulpp
ID: 36970716
Sorry mgfranz, when I opened the window the comment wasn't there, and I had the window open for a while until I answered.  No harm meant.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question