RegisterForEventValidation can only be called during Render();

Error : RegisterForEventValidation can only be called during Render();


RegisterForEventValidation can only be called during Render(); during export of Gridview to excel or word or csv in double Gridview Or ListView Or Detailsview Access in Same Form using got this Errors use this Methods.


Show this Errors

RegisterForEventValidation can only be called during Render();



The Errors  Display in whereever in form using Render Control ().

Add the @Page Directives

 EnableEventValidation ="false" 


                        Html Coding


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




Code Behind 

Rendering Control


 public override void  VerifyRenderingInServerForm(Control control)
    {
        //base.VerifyRenderingInServerForm(control);
    }









Validation to Check Terms and Conditions Checkbox Checked or Not Using Asp.Net C#

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">
   <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>


                       C# Coding



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






                                

Check Terms and Conditions Checkbox Checked or Not Using jQuery Validation

Check Terms & Condition


 JQuery Validation for terms and conditions checkbox checked or not  check Terms and Conditions checkbox selected or not using jQuery or restrict user to accept terms and conditions using jQuery.

If  Checked Checkbox  After  Control  to Agreed  Terms and Conditions.

if  Not Checked  checkbox Control  to Not Agreed  Terms and Conditions.



DEMO




  JQuery Coding


 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
    <title></title>

     <%--  Terms Condition  JQuery Coding Start--%>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#btnSave').click(function () {
                if ($('#ChkTermsCondition').is(':checked')) {
                    alert('Your Agreed Terms & Conditions')
                }
                else {
                    alert('please check terms & conditions')
                }
            })
        })
    </script>

        <%--  Terms Condition  JQuery Coding End--%>

      </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>


First - Add Web Form - Select  Labels & Textboxes & Chexkbox & Button


Name - Textbox Id change (required).







Next  -  CheckBox Id  Name Change (Required)









Next - Change Button Id(Required)









Next  - JQuery   Coding for  Check Terms & Conditions 










Next - Coding for  Labels & Textboxes & CheckBoxes







                 


Next - F5 Run the WebForm -  Click the Check Button & UnSelect CheckBox








PopUp Show  - Check the Terms & Conditions










Next - Click the Check Button & Select  CheckBox









PopUp Show Agreed  Terms & Condition