Click here to Skip to main content
15,898,791 members

Comments by Reesha Santhosh (Top 1 by date)

Reesha Santhosh 16-Mar-13 16:56pm View    
When I used Solution 1, I got an error message that read - "ASP.default_aspx' does not contain a definition for 'CheckValidation' and no extension method 'CheckValidation' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)"
Can anyone tell me why this is occuring? I am pasting below the code.

<script language="javascript" type="text/javascript">
function CheckValidation() {
var chk1 = document.getElementById("<%=CheckBox1.ClientID%>");
var chk2 = document.getElementById("<%=CheckBox2.ClientID%>");
var chk3 = document.getElementById("<%=CheckBox3.ClientID%>");
var chk4 = document.getElementById("<%=CheckBox4.ClientID%>");
var count = 0;

if(chk1.checked)
{
count++;
}
if(chk2.checked)
{
count++;
}
if(chk3.checked)
{
count++;
}

if(chk4.checked)
{
count++;
}
if(count>2)
{
alert("You can select upto 2 checkboxes");
}
}
</script>





<br />

<asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="CheckValidation()" Text="Text1"
AutoPostBack="True" />
<br />
<asp:CheckBox ID="CheckBox2" runat="server" OnCheckedChanged="CheckValidation()" Text="Text2"
AutoPostBack="True"/>
<br />
<asp:CheckBox ID="CheckBox3" runat="server" OnCheckedChanged="CheckValidation()"
Text="Text3"
AutoPostBack="True"/>
<br />
<asp:CheckBox ID="CheckBox4" runat="server" OnCheckedChanged="CheckValidation()"
Text="Text4" AutoPostBack="True"
/>
<br />