Check whether CheckBox is checked or not in ASP.Net using C#

  ASP.NET   Thursday, January 10, 2019   1176 | No Comments Yet!!! | Not Downloaded Yet!!! | No Demo | Pawan kumar
 Tags: Check whether CheckBox is checked or not   CheckBox   asp.net codes 


Introduction

Here Pawan Kumar will explain how to Check whether CheckBox is checked or not in ASP.Net using C#

Description

In previous post I have explained Export HTML Table to PDF in ASP.Net with C# using iTextSharp DLL Library, GridView in ASP.Net using c# tutorial, Disabled submit button after clicked using jQuery with example, Simple HTML5 Example (Canvas) with Example Source Code, Create or Generate QR Code in ASP.Net using C#, ASP.NET : Source Code to ASP.NET : Source Code to Get GridView CheckBox Selected Rows jQuery, and many more articles.

Now I will explain How to Check whether CheckBox is checked or not in ASP.Net using C#

So follow the steps to learn Check whether CheckBox is checked or not in ASP.Net using C#

ASPX Code(filename: CS.aspx)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CS.aspx.cs" Inherits="CS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>asp.net source code - Check whether CheckBox is checked or not in ASP.Net using C# and VB.Net</title>
    <style type="text/css">
        body
        {
            font-family: Arial;
            font-size: 10pt;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:CheckBox ID="chkAadhaar" Text="Do you have Aadhaar?" runat="server" />
    <br />
    <br />
    <asp:Button ID="btnCheck" Text="Check" runat="server" OnClick="ButtonClicked" />
    </form>
</body>
</html>

Code Behind(Filename:- CS.aspx.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CS : System.Web.UI.Page
{
    protected void ButtonClicked(object sender, EventArgs e)
    {
        if (chkAadhaar.Checked)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('CheckBox checked.');", true);
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('CheckBox not checked.');", true);
        }
    }
}

 

Conclusion:

So, In this tutorial we have learned, Check whether CheckBox is checked or not in ASP.Net using C#

Download Source Codes


Post Comments

if you have some suggestion, question, request on Check whether CheckBox is checked or not in ASP.Net using C#.

Please use the comment box to express your views.

 

Comments: