0

I have the following HTML code which displays a CHECKBOX input:

<label class="label_check" for="sample-check">
    <input name="sample-check" id="sample-check" value="1" type="checkbox" />
    Sample Label
</label>

Screenshot:

enter image description here

Whether a user clicks on the box or the text, the option gets selected.

What ASP control can I use so it works the same way it does in HTML? The reason being is I will be getting some column from my SQL table and create as many of those checkboxes in my page as there are columns from C#.

3
  • 1
    You can use the <asp:Checkbox /> user control. Commented May 6, 2014 at 16:55
  • Are you using MVC? or Asp.Net webforms ? Commented May 6, 2014 at 17:03
  • Just using Asp.net controls by itself for now and trying to see if it will produce the same result. I am trying to emulate this: http://webdesign.maratz.com/lab/fancy-checkboxes-and-radio-buttons/demo.html Commented May 6, 2014 at 17:04

1 Answer 1

1

As @Tasos Said in the Comments. You can use

<asp:Checkbox id="sample_check" runat="server" text="Sample Label"/>
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you. The ID will fail as it will not be valid.
I wondered about that but I couldn't remember for sure. I will Update my sample.
Once you get the checkboxes and radiobuttons added you're just going to have to work on styling. That's the tricky part.
That could have something to do with the with of the containing element. For instance if it is inside a <div> make sure that the <div> is wide enough.

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.