CHECKBOX CHECK 
Validation for terms and conditions checkbox checked or not check terms and conditions checkbox selected or not using c# or restrict user to accept terms and conditions using Asp.net c#.
If Checkbox Checked = True Agreed
If Checkbox Checked = False Not Agreed
DEMO

Html Coding
<html xmlns="http://www.w3.org/1999/xhtml">
                           
First Add - New Web Form - Select Labels & TextBoxs & CheckBox & Button - Textbox Id Change(Required)
Next - Checkbox Id Change(Required)
Next - Button Id - Change (Required)
Next - Create Table(terms) - Add Two Fields
Next - Double Click Check Button
                     
Next - Add - NameSpaces & DataBase Connection for Table Access
Next - Write Coding For Checkbox Condition Check After Insert Query
Next - F5 Click - Run the Program - Enter Textbox Values - Click - Check Button & Checkbox UnSelect
PopUp - Show - Select Terms & Condition
Enter Textbox Values - Click - Check Button & Checkbox Select
PopUp Show - Agreed Terms & Condition & Insert Textbox Values
DataBase Table(terms) Inserted Values
                                
Validation for terms and conditions checkbox checked or not check terms and conditions checkbox selected or not using c# or restrict user to accept terms and conditions using Asp.net c#.
If Checkbox Checked = True Agreed
If Checkbox Checked = False Not Agreed

Html Coding
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
    <title></title>    
      </head>
   <body>
    <form id="form1" runat="server">
    <div>              
          <table>
            <tr><td>
                <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
                </td><td>
                    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                </td></tr>
               <tr><td>
                <asp:Label ID="Label2" runat="server" Text="Mobile"></asp:Label>
                </td><td>
                    <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
                </td></tr>
            <tr><td> Check Status:</td><td>
                <asp:CheckBox ID="ChkTermsCondition" runat="server" />
          Agree Terms & Conditions</td></tr>
            <tr><td></td><td><asp:Button ID="btnSave" runat="server" Text="Check"  />
                </td></tr>
        </table>
    </div>
    </form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Termss : System.Web.UI.Page
{
    SqlConnection con;
    SqlCommand cmd;
    SqlDataAdapter adp;
    SqlDataReader rd;
    DataSet ds;
    string query;
    public void dbcon()
    {
        string connn = (System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());
        con = new SqlConnection(connn);
        con.Open();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        dbcon();
        if (ChkTermsCondition.Checked == true)
        {
            query = "insert into terms(name,mobile)values('" + txtName.Text + "' ,'" + txtMobile.Text + "')";
            cmd = new SqlCommand(query, con);
            cmd.ExecuteNonQuery();
            Response.Write("<script>alert('Terms & Condition Accepted')</script>");
        }
        else
        {
            Response.Write("<script>alert('Please Select Terms & Condition')</script>");
        }
    }
}
First Add - New Web Form - Select Labels & TextBoxs & CheckBox & Button - Textbox Id Change(Required)
Next - Checkbox Id Change(Required)
Next - Button Id - Change (Required)
Next - Create Table(terms) - Add Two Fields
Next - Double Click Check Button
Next - Add - NameSpaces & DataBase Connection for Table Access
Next - Write Coding For Checkbox Condition Check After Insert Query
Next - F5 Click - Run the Program - Enter Textbox Values - Click - Check Button & Checkbox UnSelect
PopUp - Show - Select Terms & Condition
Enter Textbox Values - Click - Check Button & Checkbox Select
PopUp Show - Agreed Terms & Condition & Insert Textbox Values
DataBase Table(terms) Inserted Values















 
 
.gif) 
 
 
 
 
 
0 comments:
Post a Comment