Validating Checkbox
-
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 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>
IS IsActiveCheckBox your checkbox's ID? If yes take it as ElementID Try this code
args.IsValid = document.getElementById('IsActiveCheckBox').checked;
Best Regard Pathan---------------------------------------------------
-
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>
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