Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Validating Checkbox

Validating Checkbox

Scheduled Pinned Locked Moved ASP.NET
helpjavacsssysadmintools
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    seemamltn
    wrote on last edited by
    #1

    I have a grid view. In that gridview I have somecheck boxes in EditItemTemplate. I need to validate those check boxes. I am using customValidate controls and java script to validate check boxes. but it gives me error message that IsActiveCheckBox is not found in current context. Mat be checkbox is in EditItemTemplate field. I am not sure. How can I fix this. e'g function ValidateIsActiveCs(source, args) { args.IsValid = document.getElementById('<%=IsActiveCheckBox.ClientID %>').checked; } <asp:CheckBox ID="IsActiveCheckBox" runat="server" Checked='<%# Bind("MyColumn") %>' /> <asp:CustomValidator ID="cvlIsActive" runat="server" ClientValidationFunction="ValidateIsActiveCs" ErrorMessage="This field should be checked">*</asp:CustomValidator></td> <div class="ForumSig">seema</div></x-turndown>

    I S 2 Replies Last reply
    0
    • S seemamltn

      I have a grid view. In that gridview I have somecheck boxes in EditItemTemplate. I need to validate those check boxes. I am using customValidate controls and java script to validate check boxes. but it gives me error message that IsActiveCheckBox is not found in current context. Mat be checkbox is in EditItemTemplate field. I am not sure. How can I fix this. e'g function ValidateIsActiveCs(source, args) { args.IsValid = document.getElementById('<%=IsActiveCheckBox.ClientID %>').checked; } <asp:CheckBox ID="IsActiveCheckBox" runat="server" Checked='<%# Bind("MyColumn") %>' /> <asp:CustomValidator ID="cvlIsActive" runat="server" ClientValidationFunction="ValidateIsActiveCs" ErrorMessage="This field should be checked">*</asp:CustomValidator></td> <div class="ForumSig">seema</div></x-turndown>

      I Offline
      I Offline
      Imran Khan Pathan
      wrote on last edited by
      #2

      IS IsActiveCheckBox your checkbox's ID? If yes take it as ElementID Try this code args.IsValid = document.getElementById('IsActiveCheckBox').checked; Best Regard Pathan

      ---------------------------------------------------

      1 Reply Last reply
      0
      • S seemamltn

        I have a grid view. In that gridview I have somecheck boxes in EditItemTemplate. I need to validate those check boxes. I am using customValidate controls and java script to validate check boxes. but it gives me error message that IsActiveCheckBox is not found in current context. Mat be checkbox is in EditItemTemplate field. I am not sure. How can I fix this. e'g function ValidateIsActiveCs(source, args) { args.IsValid = document.getElementById('<%=IsActiveCheckBox.ClientID %>').checked; } <asp:CheckBox ID="IsActiveCheckBox" runat="server" Checked='<%# Bind("MyColumn") %>' /> <asp:CustomValidator ID="cvlIsActive" runat="server" ClientValidationFunction="ValidateIsActiveCs" ErrorMessage="This field should be checked">*</asp:CustomValidator></td> <div class="ForumSig">seema</div></x-turndown>

        S Offline
        S Offline
        Sherin Iranimose
        wrote on last edited by
        #3

        Hi, Write a server side Function

        public string GetCheckBoxId()
        {
        CheckBox chk = (CheckBox)GridView1.Rows[rownum].Cells[cellno].FindControl("IsActiveCheckBox");
        return chk.ClientID;
        }

        then use this function inside java script args.IsValid = document.getElementById('<%=GetCheckBoxId()%>>').checked;


        To succeed, we must first believe that we can. Sherin Iranimose


        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups