I don't have any experience on events & delegates. Been trying to do something from what I found on SO and other sources over internet for past few days.
What I'm trying to do is a custom OnPageChange event for our custom pagination. After I (hopefully) did that, I'm told to do three more things;
1 - An "onclick event" inside our control
2- Making all linkbuttons to call this onclick event
3- Raising OnPageChange event from buttonclick of linkbuttons.
So far I did these;
Inside our custom pagination control (name is PagingControl)
public class PageChangeEventArgs : EventArgs
{
private int PageNum;
public PageChangeEventArgs(int PageNum)
{
this.PageNum = PageNum;
}
public int Page
{
get
{
return PageNum;
}
}
}
public class ClickEventArgs : EventArgs
{
public ClickEventArgs()
{
}
}
public delegate void PageChangeHandler(object sender, PageChangeEventArgs e);
public delegate void PageChangeClickHandler(object sender, ClickEventArgs e);
//------------------------------------------------------------------------
public partial class PagingControl : System.Web.UI.UserControl
{
//------------------------------------------------------------------------
public event PageChangeHandler PageChange;
protected virtual void OnPageChange(PageChangeEventArgs e)
{
PageChange(this, e);
}
public event PageChangeClickHandler PageChangeClick;
protected virtual void OnPageChangeClick(ClickEventArgs e)
{
PageChangeClick(this, e);
}
//------------------------------------------------------------------------
.
.
.
}
Also, I'm trying to let the OnPageChange know which page it is by sending command arguments from buttons. An exampe;
btnNext.Text = String.Format("<a href=\"{0}\"><b>{1}</b></a> ",
GetPagingUrl(Convert.ToString(this.CurrentPageId + 1)), "<img src='../../img/next.gif' border='0' />");
btnNext.CommandArgument = Convert.ToString(this.CurrentPageId + 1);
These are all so new and alien to me, I'm lost at how will I get the buttons and the eventhandler talk.
I mainly used this page among many others to get things done: http://www.windowsdevcenter.com/pub/a/dotnet/2002/04/15/events.html