简体   繁体   中英

Fire event with repeater

I'm using a Repeater, there is a button for each item. When I click on one of these buttons asp.net returns me the following error:

Invalid postback or callback argument

But when I add the Page directive EnableEventValidation = "false" on my page, no error but does not fire my event.

protected void Page_Load(object sender, EventArgs e)
{
    if (Session["user"] != null)
    {
        Customer activeCustomer = (Customer)Session["user"];
        Response.Write("Welcome " + activeCustomer.FirstName + " " + activeCustomer.LastName + " | Offer count:" + activeCustomer.OfferLimit);
        if (!IsPostBack)
         {
             ProdRepeater.DataSource = CampaignDataProcess.getDailyCampaign();
             ProdRepeater.DataBind();
         }
    }
    else
    {
        Response.Redirect("Login.aspx");
    }
}

I have already tried if(!IsPostBack) in page load.

How can this be resolved?

if you are using more than form in your aspx file, you can not use your events. I had a problem like your and i solved my problem deleting that form tags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM