Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to show message if no any single item selected then show message check atleast one item.plz help me?
Posted

1 solution

C#
if (BtnTitleSave.Text == "Save")
           {
               int count = 0;
               for (int i = 0; i < ChklistDomain.Items.Count; i++)
               {
                   if (ChklistDomain.Items[i].Selected == true)
                       count++;
               }
               if (count == 0)
               {
                   ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "alert(' Atleast select one domain !')", true);

               }
               else
               {
//Your condition here

}

or u can use javascript check below

C#
function doSubmit()
{
  var c = document.getElementsByTagName('input');
  for( var i = 0; i < c.length; i++ )
  {
    if( c[i].type.toLowerCase() == 'checkbox' && c[i].checked )
    {
      // A checkbox was checked, good user
      return( true );
    }
  }
  // No checkbox checks, bad user
  return( false );
}




hope this helps u:)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900