3

I'm working in ASP.NET and I have a CheckBoxList where I want one of the options to be basically like "Other: _." So I need to include a textbox where the user can fill in their own option. It doesn't seem like there's a way to include a textbox inside of a checkboxlist, however. What's the best way to make this work?

-UPDATE-

If using a separate textbox control, how do I position it so it will align correctly with the checkbox?

1
  • playing css with firebug/developer tool open is the best self taught ever. :) Commented Dec 17, 2010 at 4:12

3 Answers 3

3

Make the textbox a separate control on the page, then in your codebehind, check to see if other is checked. If it is, pull the value of the textbox, and use that.

To answer the question in your edit: You'll have to play with the CSS of the page to get it positioned correctly. How you do it depends on the layout of the page, among other things. I recommend posting some of the HTML from your page in another question and ask about how to position them.

Sign up to request clarification or add additional context in comments.

Comments

0

What @Kyle Trauberman said...

Make the textbox a separate control on the page, then in your codebehind, check to see if other is checked. If it is, pull the value of the textbox, and use that.

Plus use javascript to hide or gray out the option unless the checkbox is selected.

Comments

0
string test="";
<asp:CheckBoxList ID="chk_list" runat="server">
<asp:ListItem Value="00">xxxx</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="other" runat="server"></asp:TextBox>

inside the for loop

if (chk_list.Items[i].Value == "00")
{
    test +=chk_list.Items[i].Text + other.Text;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.