Check to see if Checkbox is checked

 

Hello All,

Currently my application allows user to select the days which they worked and the days are presented in the form of checkboxes which means there are 7 checkboxes for Monday to Sunday. The problem is: I want my users to at least check one box: How do I write the code in VB.NET to ensure that at least one box is checked? I have no totally no idea at all.

 Any experts care to shed some light? Thanks!


Sincerely Yours,
Abupapa
0
abupapa
2/11/2009 4:41:34 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

7 Replies
682 Views

Similar Articles

[PageSpeed] 24

hi,

Pls go through the link below: This is a very good article.. i think this will meet your requirement.

http://codeclimber.net.nz/archive/2007/07/19/How-to-add-a-required-validator-to-a-CheckBoxList.aspx


Thanks and Regards
Nimesh Prabhakar


Mark this post as "ANSWER", if it helped you..
0
nimeshprabhakar
2/11/2009 7:55:00 AM

Use CheckBoxList control for this purpose. use the following code

for dim i as integer = 0  to CheckBoxlist1.Items.Count

if CheckBoxlist1.Item(i).Text = "Date to check"

CheckBoxlist1.Item(i).Checked = True

End if

Next

// CheckBoxlist1.Item(i).Text will contains the date of the week you have assigned


Muhammad Shoaib
Software Engineer,
Lahore, Pakistan
www.heartofpakistan.com (U/C)
--------------------------------
Mark it as ANSWER if it Helps U
0
mshoaib83
2/11/2009 7:59:19 AM

Hi,

Check the following code

 

  

Dim checkCount As Integer = 0

        For Each con As Control In Page.Form.Controls
            If con.GetType().FullName = "System.Web.UI.WebControls.CheckBox" Then
                Dim cb As CheckBox = CType(con, CheckBox)
                If cb.Checked Then
                    checkCount += 1
                End If
            End If
        Next
 
now put a check on checkCount if it is zero it means nothing is selected :) 
cheers 
 
Dont forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
http://www.aghausman.net
0
aghausman12
2/11/2009 8:01:33 AM

to make sure that at least one checkbox is checked

Dim check as Boolean = False

For i as integer = 0 To  CBL.Items.Count -1

if CBL.Items(i).Checked = True

check = true

end if

Next

if check = True

// that means that there is at least one of the items is selected

end if

0
Roba
2/11/2009 8:14:27 AM

Hi,

If you want only one selection then eas method is use radiobutton list.

or you want to use check box list then validate it with custom validator the check out this http://forums.asp.net/t/1370147.aspx

 

Thanks,

Farooq


Mark as answer if this post helpfull to you.

Don't be afraid to be wrong; otherwise you'll never be right.
0
susain
2/11/2009 8:26:43 AM

dear,

use javascript for this:

function ValidateCheckboxSelection()

{

var flag;

all=document.getElementsByTagName("input");

for(i=0;i<all.length;i++)

{

if(all[i].type=="checkbox")//Checking if it is a Checkbox

{

if(!(all[i].disabled) && (all[i].checked))

{

flag=
true;

}

}

}

if(!flag)

{

alert(
"Please select at least one of the record(s)");return false;

}

else

{

return true;

}

}

</script>

just call this method on the button onClientClick="return ValidateCheckboxSelection()" event.


Kind Regards,
Saurabh Sharma

only dead fish swim along the flow of river, learn to make your own way.


Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread
0
saurabhsharma18
2/11/2009 9:05:58 AM

Hello to All who posted a reply,

 Thanks for your help! I have managed to get it working!


Sincerely Yours,
Abupapa
0
abupapa
2/12/2009 12:50:36 AM
Reply:

Similar Artilces:

checking checkbox is checked or not using checkbox.checked
Hi,my checkbox is<asp:CheckBox ID="Chkcity" runat="server" Text="My own city"  OnCheckedChanged="EventHandler"/>code behind: Private Sub Chkcity_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Chkcity.CheckedChangedif (Chkcity ...............)end if End SubERROR    'EventHandler' is not a member of 'ASP.bpoaddjob_aspx'.    Please Mark the post as "ANSWER" if it helps you I think it should be like this:<asp:CheckBox ID="Chkcity"...

Check All Check Box While Check Header CheckBox
 hello...I have two grid on same page...both grid contains header checkbox and item checkbox i want that if use check header checkbox then all item check box checked,i have javascript for this functinality but problem is that when i click on header check box of first grid then checkbox of second grid also checked that i dnt want i want to perform this operation on one grid at one time.i have attache my script also...plz help me....thanks<script type="text/javascript">        function SelectAll(ID)      &nbs...

Check One CheckBox To Check All CheckBoxes
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked. I set the AutoPostBack property of the CheckBox in the Header to True & am invoking a sub named CheckAllRows on the CheckedChanged event of this CheckBox. The CheckBox in the Header exists within the HeaderTemplate of a TemplateColumn in the DataGrid & the rest of the CheckBoxes reside within the ItemTemplate of the same TemplateColumn. This is the code (the ID of the CheckBox in the Header...

Check-in/Check-out
I'm having some difficulty with powerbuilder's check-in/check-out operation. When I check an object back in, the .pbl the object is being moved from is destroyed. Has anyone else experienced this and is there a fix? Cheers, Tom Thomas F. (Tom) Massey wrote: > > I'm having some difficulty with powerbuilder's check-in/check-out > operation. When I check an object back in, the .pbl the object is > being moved from is destroyed. > > Has anyone else experienced this and is there a fix? > > Cheers, > > Tom The prob...

Check In/Check out
I am using PowerBuilder 9. The undo check out is right next to the check in. This is a big problem! I so easy to select Undo check out and lose all of your changes. I lost 8 hours of work yesterday because of it. I know I should be more careful. However, there should be a "Are you sure" some where also. PLEASE FIX!!!!!!!!!!!!! -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ This isn't the tech support line, it's an end-user forum. If you want to report a bug, use CaseXpress and either open a case or report a bug ...

Checked=Checked
 I am dynamically writing out checkboxes on a page.  I have 2 link buttons on the page that sets a boolean variable to True or False. This boolen is set in Page_PreInit and is used to Select or Deselect all the Checkboxes as they are written out. A Select ALL, Deselect ALL type of thing. At least that is the plan. As the page is being written out I do this for each checkbox and then add it to a table cell control that it added to a table row and on. tc is the table cell.  Dim chkItem As CheckBox = New CheckBox chkItem.ID = "chkRecommend" + drMember("ID")...

Check out/check in
Hello How can i use the process check out/check in in PowerBuilder 8.0.3 ? We work in network. The Source Control is PB Native. I don't understand what is the parameters of Source Control ? Thank you Have you looked the PB8 User's guide? Chapter 3 talks about source control. -- Evita Chapa Senior Systems Analyst II Command Technologies Inc. <Herv� Bareth> wrote in message news:3f69ba0a.592b.846930886@sybase.com... > Hello > > How can i use the process check out/check in in PowerBuilder > 8.0.3 ? We work in network. The Source Control is PB Na...

Check In Check Out
I have some source code that I need to modify and it was sent to me in a Registered status. Therfore, when I open any object it says " 'object name' is registered but not checked out and therefore can not be overwritten. Open anyway?" Then when I try to check it out, I get "PBNative checkout not allowed for registered objects." How can I get around this? When I look under the "Source" menu, all the items concerning registered are grayed out. TIA Option1:Copy the object(Only) to someother pbl and try . Option2:If You have any SCC Expo...

Check in
Hi all. I am migrating from PB 7.0 to PB 10.5, After migrating my first application i am trying to work on my first window but i'am not able to find out the way to CHECK it OUT. Wher do i can find "check out/check in" functions ?? TIA Mario Parietti What source control are you using? Have you configured it? Right click on your Workspace and check the source control tab to see if you've got it set up. "Mario Parietti" <mparietti@intercad.ch> wrote in message news:451283e0$1@forums-1-dub... > Hi all. > I am migrating from PB...

See if checkboxes were checked in form submission
Hi All,I have a series of checkboxes on my form. I've not used a checkboxlist as it creates a table in HTML and I want to keep this table-less.I have a series of <div>s (12 in all) as follows:<div class="wide-row"> <asp:CheckBox ID="cbxTravel" Text="Travel" runat="server" /> </div> I can't do a foreach as they're not all in one control. How can I get the status of each checkbox and write them into the body of my email like objMail.Body = objMail.Body + "Travel? " + // status of checkboxobjMail.Body...

Check out/check in
Hello How can i use the process check out/check in in PowerBuilder 8.0.3 ? We work in network. The Source Control is PB Native. I don't understand what is the parameters of Source Control ? Thank you Better to ask this in the source control group. Lots of posts on PBNative -- Evita Chapa Senior Systems Analyst II Command Technologies Inc. <Herv� Bareth> wrote in message news:3f69678e.7b3a.846930886@sybase.com... > Hello > > How can i use the process check out/check in in PowerBuilder > 8.0.3 ? We work in network. The Source Control is PB Native. ...

check to see if check box is checked onclientclick button event.
i have a check box similiar to "please check the box if you have read and understand what i placed there".  Right now i have the submit button doing a postback and checking to see if the checkbox is checked. great but inefficient.  I would like to use the onclientclick to check if the checkbox is checked and if not alert the user to check the box.  Thank you in advance and your help is appreciated.  I am very new to this javascript stuff so please spare me.  I am keeping the code inside my aspx file, not in codebehind. Jake You should look at using a validatio...

Why don't I see the "use master page" check box when I add a new web form to my web app?
From what I've read I should see this check box whenever I add a new web form but I don't.  Should I add something else instead of a web form or is there a flaw in my web apps install? Woot! I found the answer!  There is an item in the add new item dialog box called web content form! If you use this instead of the web form then all is good and warm fuzzy!...

Javascript for validation if checkboxes are checked in web form
I have 26 checkboxes on my form. I want to use javascript to loop thru the controls and check to see if at leat 5 are checked. Any suggestions?? I don't know much about javascript. Thanks in advance!!! Hi Read on all.tag collection of the document. You can get all the "INPUT" objects of your document and check if it is of type "checkbox". To see if the checkbox is checked use the "checked" property of that object. e.g. function countCheckItems() { var items = document.body.all.tags("INPUT"); var i; var iSelec...

Web resources about - Check to see if Checkbox is checked - asp.net.web-forms

Checkbox - Wikipedia, the free encyclopedia
In computing , a checkbox ( check box , tickbox , or tick box ) is a graphical user interface element ( widget ) that permits the user to make ...


XYplorer adds flat select tool, timestamping, sticky checkbox selection and improves portable device ...
... them a date previously copied to the clipboard. sc_* - *.doc matches both files beginning sc_ and those with a .doc extension. Sticky checkbox ...

Beware of checkbox marketing!
... able to sell the product at all and the company will go out of business. (sometimes in those exact words) These are the two edges of the checkbox ...

Disable Lion’s Resume Checkbox When Shutting Down [Video How-To]
One of the most annoying features in OS X Lion for me has been the little checkbox on the shutdown dialog box that states, "Reopen windows when ...

A Checkbox On Your Tax Return Helped Kill Public Campaign Funding
You already hate tax season, and as you move wearily through the cold calculations of the 1040 form, you come across a familiar checkbox. It’s ...

Google's Clever Plan to Replace CAPTCHA With a Checkbox
CAPTCHAs are an unfortunate side effect of the internet. They're those irritating collection of numbers and letters morphed into some Surrealist ...

Great news: New EEOC checkbox category emerges
"Bow-tie'n white boys"? Hey, I tried to anticipate the next expansion in ethnic categorization yesterday with my proposal for recognition of ...

Checkbox Syndrome: Why We Spend Money on Things We Don't Need
Ever been overwhelmed by the temptation to buy the latest shiny thing because it's got another checkbox in the features column? We call this ...

Magid: Google ditching CAPTCHA for 'I'm not a robot' checkbox
We need better security, but we need to find systems that are hard for bad guys to break but easy for good folks to use. Google is one of the ...

Resources last updated: 12/30/2015 6:45:14 AM