Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 14th, 2008, 08:35 AM
Authorized User
 
Join Date: Aug 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Radiobuttons

Hi All,

I have an app that I wish to have 2 radiobuttons (or a radiobuttonlist)

Currently I can't seem to get any c# code to do anything, even though I have my oncheckchanged command in the aspx in the appropriate tag. Is there anything else i'm missing?

 
Old April 14th, 2008, 12:46 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:Is there anything else i'm missing?
Not entirely sure about you, but what we are missing is sample code of the problematic page.... ;)

Post the relevant parts of the so we can take a look at it....

Cheers,


Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old April 15th, 2008, 04:08 AM
Authorized User
 
Join Date: Aug 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Haha fair do's!

My aspx

Code:
<asp:RadioButtonList ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
            <asp:ListItem>Internal</asp:ListItem>
            <asp:ListItem>Commercial/General/NHS</asp:ListItem>
        </asp:RadioButtonList>


c#
Code:
 protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        MessageBox.Show("Radiobutton");
    }
any thoughts?
 
Old April 15th, 2008, 12:03 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Certainly. You are mixing Web Forms and Win Forms. Take a look at this:

MessageBox.Show("Radiobutton");

Where do you think this fires? At the client? Nope; this fires at the server and does NOT translate into something like an alert() call. In ASP.NET applications, you can't use MessageBox.Show. I think it's just swallowed by the framework.

Try writing to a Label instead. E.g. add a <label /> control to the page and then try:

Label1.Text = "Radiobutton";

Maybe you are new to ASP.NET? If so, you may want to check out my new book Beginning ASP.NET 3.5, located here: http://www.wrox.com/WileyCDA/WroxTit...47018759X.html

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old April 16th, 2008, 04:50 AM
Authorized User
 
Join Date: Aug 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, MessageBox is a c# method I have written that uses Javascript, so it can popup buttons on the clients. The radiobuttons reference si just to pop up a textbox saying radiobutton to see ti go into the event, but this isn't the case.

 
Old April 16th, 2008, 05:07 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

But did you try out the label I suggested? Maybe your MessageBox code isn't working?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old April 18th, 2008, 10:29 AM
Authorized User
 
Join Date: Aug 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Apologies, I must have been having a bad day. I have got it working now. I wasn't posting back the changes so couldn't see my changes...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to pull values from dynamic radiobuttons kwilliams ASP.NET 2.0 Professional 0 November 14th, 2008 11:54 AM
DataBinding with Radiobuttons vgsgowrisankar C# 2005 0 May 8th, 2008 05:15 AM
Assigning radiobuttons hydra14 C# 7 June 5th, 2004 12:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.