ASP.NET: checkboxlist with text box?

I work in ASP.NET and I have a CheckBoxList where I want one of the options to be basically like "Other: _ ." Therefore, I need to include a text box in which the user can fill out his own option. However, there seems to be no way to include the text box inside the checkboxlist. What is the best way to make this work?

-update -

If you are using a separate text box control, how do I put it so that it aligns correctly using the checkbox?

+3
source share
3 answers

Make the text box a separate control on the page, and then check in your code line if another is checked. If so, pull the value of the text box and use it.

To answer the question in your editing: You will need to play with the CSS page in order to position it correctly. How you do this depends, in particular, on the layout of the page. I recommend posting part of the HTML from your page in another question and asking how to place them.

+3
source

What @Kyle Trauberman said ...

Make the text box a separate page control, then in your code, check if the other is checked. If it is, pull out the value of the text box, and use it.

javascript , .

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>

for

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

Source: https://habr.com/ru/post/1780752/


All Articles