validation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
<script language="javascript" type="text/javascript">
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>
 
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
<script language="javascript" type="text/javascript">
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>

I tried your code out and didn't get the error you had. However when
my submit button was clicked and the checkbox wasn't checked it
displayed the Text "*" not the ErrorMessage from the CustomValidator.
 
Back
Top