Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 December 6th, 2004, 01:05 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checkbox list validation

Hi
I need to do the validation for checkboxlist as minimum selection must be 3 from the list.Then i have to pass the selected values to the next page with text boxes. Can anyone help me to do the validation and dosplay the selected values in the next page.

Thanx
Lily

 
Old December 6th, 2004, 08:30 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please reply this query, its very urgent.

 
Old December 7th, 2004, 09:39 AM
Authorized User
 
Join Date: Jul 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aravwind Send a message via Yahoo to aravwind
Default

hi lily....
Tis will work fine.
But i leave a small work for u to finish ur task.
i.e., u need to check for minimum three checked items.
its also simple. A variable "intCount" is declared and incremented in the loop here.
use it and chk ur appropriate validation.



ASP.NET, code behind: VB.NET

In chkboxlist1.aspx.vb
------------------------

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim intCount, i
        Dim StoreListItems As String
        Dim Store As String
        Dim arr()
        hdnStore = ""
        StoreListItems = ""
        intCount = 0
        For i = 0 To CheckBoxList1.Items.Count - 1
            If CheckBoxList1.Items(i).Selected = True Then
                intCount += 1
                Store += i & ","
            End If
        Next

        arr = Split(Store, ",")
'hdnChk1 is a hidden variable
        hdnChk1.Value = CheckBoxList1.Items(arr(0)).Text
        hdnChk1.Value = hdnChk1.Value + "," + CheckBoxList1.Items(arr(1)).Text
        hdnChk1.Value = hdnChk1.Value + "," + CheckBoxList1.Items(arr(2)).Text

        Response.Redirect("chkboxlist2.aspx?arg=" + hdnChk1.Value)

    End Sub





In chkboxlist2.aspx.vb
------------------------

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim arr()
        Dim displayItems As String
        displayItems = ""
        displayItems = Request.QueryString("arg")

        arr = Split(displayItems, ",")
        TextBox1.Text = arr(0)
        TextBox2.Text = arr(1)
        TextBox3.Text = arr(2)
    End Sub
 
Old December 8th, 2004, 02:19 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for asking again but I want this code in C#.

 
Old December 8th, 2004, 02:34 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Try this:

http://developerfusion.com/utilities...btocsharp.aspx

Have you been able to figure out the DataGrid issue?? (A little feedback every now and then would be nice).

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 9th, 2004, 07:49 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am familiar of this link. This doesn't work always.
For that datagrid issue,I initialised the datagrid as 0, which is given in reply. Somewhat this is helpful but i go back with that back button this shows the same error otherwise its working fine.

 
Old December 10th, 2004, 03:33 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now my requirement has changed, i want the validation for checkboxes.
There is a table on which each row consists of 6 checkboxes.Like that i have 25 rows with 6 checkboxes.I have to validate that user must check 3 checkboxes not less than 3 not more than three.
Can anyone help me with the code.I am working in C#.






Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckBox Validation maheshoo7 Pro JSP 3 March 10th, 2008 07:55 AM
checkbox validation on client side using Javascrip sansircar ASP.NET 1.0 and 1.1 Professional 0 October 17th, 2005 07:43 PM





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