I've got a class to make Templates for different repeaters in my page. in one of these repeaters a linkbutton is needed. This LinkButton needs an event that is in a .cs file somewhere else in the website. (coz the event is used by other controls too) In the event some of the controls of that page ar accessed so I thought it would be easy to keep the Eventhandler there too.
My problem is that I cant seem to get the eventhandler to work. Basic code in the cass is
In the Class:
In the page_load of the Aspx file where the eventhandler is:
Anyone have some tips?
My problem is that I cant seem to get the eventhandler to work. Basic code in the cass is
In the Class:
Code:
public delegate void LinkButtonClickHandler(Object sender, EventArgs e); void NewsItem_DataBinding(object sender, EventArgs e) { lbLeesMeer.Click += new EventHandler(lbLeesMeer_Click); lbLeesMeer.ID = "lbLeesMeer" + Artikel_ID; lbLeesMeer.CommandArgument = TypeCode + ";" + Artikel_ID; } public static event LinkButtonClickHandler LinkButtonClick; protected void lbLeesMeer_Click(Object sender, EventArgs e) { if (LinkButtonClick != null) LinkButtonClick(sender, e); }
Code:
if (!this.IsPostBack) { MyTemplate.LinkButtonClick += new LinkButtonClickHandler(lbMenu_click); //lbMenu_click is the Eventhandler I want to access }
Comment