Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


custom validator checkbox asp.net

Posted on 2011-02-24
Medium Priority
Last Modified: 2012-05-11
Can someone help me creating a custom validator or a java snipte to check if at least one checkbox is checked before priting, ?

the control I am trying to validate is called CheckBoxPrintProvider1 , and I have several listviews in my page..  

<asp:ListView ID="ListView1" runat="server" DataSourceID="AccessDataSource2" Visible="False"
        ItemPlaceholderID="itemPLaceHolder1" GroupPlaceholderID="groupPlaceholder1">
            <tr id="itemPlaceholderContainer" runat="server">
                <td id="itemPlaceholder1" runat="server">
            <br />
            <table id="TableItemTemplate" runat="server" class="itemTemplateClass">
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Last_Name") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Last_Name"))="",False,True)%>'/>
                            <asp:Label ID="LabelComma" runat="server" Text=',' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Last_Name"))="",False,True)%>'/>                                                   
                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("First_Name") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "First_Name"))="",False,True)%>'/>
                            <asp:Label ID="Label3" runat="server" Text='<%# Eval("Prof_Designation") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Prof_Designation"))="",False,True)%>'/>
                        <asp:Label ID="Label4" runat="server" Text='<%# Eval("Specialty") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Specialty"))="",False,True)%>'/>
                        <asp:Label ID="Label5" runat="server" Text='<%# Eval("[Specialty2]") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Specialty2"))="",False,True)%>'/>
                        <br />
                        <asp:Label ID="Label6" runat="server" Text='<%# Eval("Address") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Address"))="",False,True)%>'/>
                        <br />
                        <asp:Label ID="Label7" runat="server" Text='<%# Eval("Address2") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Address2"))="",False,True)%>'/>
                        <br />
                        <asp:Label ID="Label8" runat="server" Text='<%# Eval("City") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "City"))="",False,True)%>'/>
                        <asp:Label ID="Label9" runat="server" Text='<%# Eval("State") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "State"))="",False,True)%>'/>
                        <asp:Label ID="Label10" runat="server" Text='<%# Eval("Zip") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Zip"))="",False,True)%>'/>
                        <br />
                        <asp:Label ID="Label11" runat="server" Text='<%# Eval("Phone") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Phone"))="",False,True)%>'/>
                        <br />
                        <asp:Label ID="Label12" runat="server" Text='<%# Eval("Fax") %>' Visible='<%# IIF(CONVERT.ToString(DataBinder.Eval(Container.DataItem, "Fax"))="",False,True)%>'/>
                        <br />
                        <asp:Label ID="lblId1" runat="server" Visible="false" Text='<%# Eval("Id") %>' />
                        <asp:CheckBox ID="CheckBoxPrintProvider1" runat="server" />
                        <asp:HyperLink ID="HyperLink1" runat="server" Text="Click to See a Map" NavigateUrl='<%# "http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" + Server.UrlEncode(Eval("Address").ToString) + "," + Server.UrlEncode(Eval("City").ToString) + "," + Server.UrlEncode(Eval("State").ToString) %>' Target="_blank" />
            <br />

Open in new window

Question by:TonyReba
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Expert Comment

ID: 34975335
Where is the check box? I see all labels.

Author Comment

ID: 35001715
asp:CheckBox ID="CheckBoxPrintProvider1" runat="server" />

Accepted Solution

jordanking earned 2000 total points
ID: 35144517
here is what i have used

<script type="text/javascript">
                    function CheckAgreement(source, args) {
                        var Agreement = document.getElementById('<%= cbAgreement.ClientID %>');
                        if (!Agreement.checked){
                            args.IsValid = false;
                        else {
                            args.IsValid = true;
                <div class="Form_Note">
                    <asp:CustomValidator ID="cvAgreement" runat="server" 
                        ErrorMessage="You must agree to the Terms and Conditions" Text="*" 
                        SetFocusOnError="True" ClientValidationFunction="CheckAgreement" 
                    <asp:CheckBox ID="cbAgreement" runat="server" />

Open in new window


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question