简体   繁体   English

带中继器的火灾事件

[英]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: 当我单击这些按钮之一时,asp.net向我返回以下错误:

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. 但是,当我在页面上添加Page指令EnableEventValidation =“ false”时,没有错误,但不会触发事件。

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. 我已经在页面加载中尝试过if(!IsPostBack)

How can this be resolved? 如何解决?

if you are using more than form in your aspx file, you can not use your events. 如果您在aspx文件中使用的表单多于表单,则不能使用事件。 I had a problem like your and i solved my problem deleting that form tags. 我遇到了像您这样的问题,并且解决了删除该表单标签的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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