用户自定义控件

 

///  定义一个事件类

public class AddedCartArgs : EventArgs

{

    /// 产品Id

    public Guid ProductId { get; set; }

}

 

///建立一个事件

public event EventHandler AddedToCart;

 

///在执行的地方调用这个事件

AddedToCart(this, new AddedCartArgs() { ProductId = ProductId });

 

编辑页面部分

 

<uc2:ProductDetails ID="ProductDetails1" runat="server" OnAddedToCart="ProductDetails1_AddedToCart"  />

 

 protected void ProductDetails1_AddedToCart(object sender, AddedCartArgs e)

 {     

        //此处为执行事件的代码

 }

相关文章:

  • 2022-12-23
  • 2021-12-04
  • 2021-06-27
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2022-02-25
猜你喜欢
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2022-01-25
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案