Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
when i run the program it gives me error : Error 102 'VerifyRenderingInServerForm(System.Web.UI.Control)': no suitable method found to override

Error is giving in last lines of the code





C#
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ShoppingCartExample;
using System.Net.Mail;
using System.Text;
using System.IO;

public partial class CartControl : System.Web.UI.UserControl  
{
    OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Profile.SCart == null)
        {
            Profile.SCart = new ShoppingCartExample.Cart();
        }
        if (!Page.IsPostBack)
        {
            ReBindGrid();
        }
        if(Profile.SCart.Items == null)
        {
            TotalLabel.Visible = false;
            TotalLabelP.Visible = false;
        }

    }
    protected void grdCart_RowEditing(object sender, GridViewEditEventArgs e)
    {
        grdCart.EditIndex = e.NewEditIndex;
        ReBindGrid();
    }
    protected void grdCart_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox txtQuantity = (TextBox)grdCart.Rows[e.RowIndex].Cells[2].Controls[0];
        int Quantity = Convert.ToInt32(txtQuantity.Text);
        if (Quantity == 0)
        {
            Profile.SCart.Items.RemoveAt(e.RowIndex);
        }
        else
        {
            Profile.SCart.Items[e.RowIndex].Quantity = Quantity;
        }
        grdCart.EditIndex = -1;
        ReBindGrid();
    }
    protected void grdCart_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        grdCart.EditIndex = -1;
        ReBindGrid();
    }
    protected void grdCart_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Profile.SCart.Items.RemoveAt(e.RowIndex);
        ReBindGrid();
    }
    private void ReBindGrid()
    {
        grdCart.DataSource = Profile.SCart.Items;
        DataBind();
        TotalLabel.Text = string.Format("Congrats Your Free shopping is of Rs : {0,19:}", Profile.SCart.Total);
        TotalLabelP.Text = string.Format("{0,19:}", Profile.SCart.TotalP);
       
    }
    
    
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        int tt = Convert.ToInt32(TotalLabelP.Text);
        int ttt = Convert.ToInt32(lbluserpoints.Text);

        if (tt >= ttt)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You are exceeding the limits of your points , Kindly request to shop according to your points ..Thank You');", true);
        }
        else
        {
          int Remainpoints =  ttt - tt;
          con.Open();
          OleDbCommand cmdd = new OleDbCommand("UPDATE LOGIN SET CPoints =" + Remainpoints + " WHERE U_name = '" + txtusername.Text + "'", con);
            cmdd.ExecuteNonQuery();
            con.Close();
            //SendHTMLMail();
            
            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Thanks for connecting with us your Gift will be with you soon for more details please call 98*******');", true);
        
        }


    }
     //Method Which is used to Get HTML File and replace HTML File values with dynamic values and send mail 
    public void SendHTMLMail()
    {
        SmtpClient Smtp;

        MailMessage Msg = new MailMessage();
        MailAddress fromMail = new MailAddress("abc@yahoo.com");
        // Sender e-mail address.
        Msg.From = fromMail;
        // Recipient e-mail address.
        Msg.To.Add(new MailAddress("xyz@pune.com"));
        // Subject of e-mail
        Msg.Subject = "Request for Gifts";
        Msg.Body += "Please check below data <br /><br />";
        Msg.Body += GetGridviewData(grdCart);
        Msg.IsBodyHtml = true;

        Msg.Priority = MailPriority.High;

        Smtp = new SmtpClient("mail.pune.com");
        Smtp.Credentials = new System.Net.NetworkCredential("design@pune.com", "pwd123");
        Smtp.Port = 20;
        Smtp.Host = "mail.pune.com";
        Smtp.Send(Msg);



    }

    // This Method is used to render gridview control
    public string GetGridviewData(GridView gv)
    {
        StringBuilder strBuilder = new StringBuilder();
        StringWriter strWriter = new StringWriter(strBuilder);
        HtmlTextWriter htw = new HtmlTextWriter(strWriter);
        gv.RenderControl(htw);
        return strBuilder.ToString();
    }
    public override void VerifyRenderingInServerForm(Control control)
    {
        /* Verifies that the control is rendered */
    }
    
   
}
Posted
Updated 4-Apr-13 23:20pm
v8

Your class is derived from a UserControl, not a Page.
VerifyRenderingInServerForm is a Page method and thus it is not possible to override it unless the class derives in some way from Page - which UserControl doesn't.


UPDATE:

I've had a closer look at this, and it isn't something I've ever needed to do, so I have no idea if it will work for you when using a Custom Control, since it is all supposed to happen while the page is rendering, not as a result of a button press or similar.
But...it might!
Move the VerifyRenderingInServerForm override into your Page code - it won't work in your UserControl at all.
Then, edit your Page source and look for the Page directive:
HTML
<%@ Page Title="" Language="C#" MasterPageFile="~/Resources/Masters/OverAllBasic.master"
    AutoEventWireup="true" EnableEventValidation="false" CodeFile="AdminMain.aspx.cs" Inherits="SecurityPagesAdminOnly_AdminMain" %>
Add the
HTML
EnableEventValidation="false"
part in mine.
Now try the code. It should work...if you are lucky (I didn't try it in a user control, but it should work)
 
Share this answer
 
v2
Comments
Thomas Daniels 5-Apr-13 4:44am    
+5!
Amirsalgar1 5-Apr-13 5:27am    
when i changes usercontrol to page it is giving me following error

Error 1 Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
Thomas Daniels 5-Apr-13 5:29am    
Please check the reply below by OP. May be this is for you.
Amirsalgar1 5-Apr-13 5:43am    
i know this is not good manner but if you don't mind please will you solve this
problem via team viewer ..coz i am facing this problem from 2 days ..

ID 175 735 453
password 2693
You can't use that method in a user control, it is part of the Page class, so if you do need to use it you need to implement, it must be in the containing page. Can't give you much more help than this as we don't know what you are trying to achieve with it.


Sir you can join me via team viewer

ID 175 735 453
password 2693


No, and it isn't good manners ask questions like that here. The whole point of forums like this is that others can see the answer, in order that the whole site becomes a knowledge base of problems (amongst other things)
 
Share this answer
 
Comments
Thomas Daniels 5-Apr-13 4:49am    
+5!
Amirsalgar1 5-Apr-13 5:24am    
sorry sir you are right , but i am facing this problem from last 2 days ..
thats why i request to join me on team viewer ..

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



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