Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 November 30th, 2006, 06:10 AM
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default radiobuttonlist + textbox

Hi !

I'm trying to create a multiple-choice survey. There are several questions. I use radiobuttonlists and checkboxlists for the answers, but still have a problem with some of them. Actually, here's what I would like to get :

Question : blablablabla?

[] answer 1
[] answer 2
[] other answer : [___________]

How can I add (and is it possible ?) a textbox just right to the last list item ? It doesn't even have to appear dynamically...

Adding it directly into my aspx file doesn't work (I guess a radiobuttonlist control must contain only listitem controls).
I tried a workaround by doing this in codebehind :

myquestion.Items[2].Text = "Other : " + "<input type='text' name='myTextBox'>"

but then I got another problem : when I click into my textbox, wich is part of the list item, it gives focus to the checkbox/radiobutton of this element... and as my textbox loses focus, I can't write anything in it !

Is there any solution, or should I change my form and not use rediobuttonlists ?

Thx by advance !
 
Old December 1st, 2006, 02:56 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi

There is no need to change your logic, just use the below in your HTML for radiobuttonlist with a textbox:
<asp:RadioButtonList ID="rdo" Runat="server">
                <asp:ListItem>First</asp:ListItem>
                <asp:ListItem>Second</asp:ListItem>
                <asp:ListItem>Others <input type="text" name="txtOthers"></asp:ListItem>
            </asp:RadioButtonList>

Now, on server side, you can fetch the value of textbox as below:

Response.Write(Request["txtOthers"].ToString());

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old December 5th, 2006, 10:38 AM
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is still the same with this solution : as the textbox is considered as a part of the label of the last listitem, whenever I click into this textbox, my radiobutton/checkbox is checked/unchecked and get the focus.

So when I click into the textbox to give focus, it loses focus instantly...

Moreover, whenever I set the Text property of the list item in codebehind (my site is multilingual) , textbox disappears, for the same reason.





Similar Threads
Thread Thread Starter Forum Replies Last Post
RadioButtonList sumith ASP.NET 2.0 Basics 0 October 2nd, 2007 11:30 PM
Get values from RadioButtonList debjanib ASP.NET 1.0 and 1.1 Basics 1 May 30th, 2006 09:45 PM
dynamic textbox shown when radiobuttonlist select debjanib ASP.NET 1.0 and 1.1 Basics 1 May 30th, 2006 09:44 PM
show dynamic textbox when radiobuttonlist selected debjanib ASP.NET 1.0 and 1.1 Professional 1 May 30th, 2006 09:42 PM
radiobuttonlist fzilz VS.NET 2002/2003 1 April 9th, 2004 10:03 AM





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