The example I'm going to give is useless for any practical purposes, but then, you have not indicated any of your practical purposes, so I think it's a fair game. I hope that it will show the approach to you and then you will be able to modify and extend it you suit your needs.
public class LinkButtonWithClack : LinkButton
{
private const string ClackMarker = "Clack";
public bool ClackMode { get; set; }
protected override PostBackOptions GetPostBackOptions()
{
var options = base.GetPostBackOptions();
if (ClackMode)
{
// That's how you specify the event argument for __EVENTARGUMENT
options.Argument = ClackMarker;
}
return options;
}
public event EventHandler Clack;
protected override void RaisePostBackEvent(string eventArgument)
{
if (eventArgument == ClackMarker)
{
this.OnClack(EventArgs.Empty);
}
else
{
base.RaisePostBackEvent(eventArgument);
}
}
protected virtual void OnClack(EventArgs e)
{
if (Clack != null)
{
Clack(this, e);
}
}
}
In this example you are creating a new server control, LinkButtonWithClack
. This control inherits from the LinkButton
server control and has an additional event, Clack
. If you set property ClackMode
to true it will start generate Clacks instead of Clicks.
Whether and event a click or clack is communicated by the second argument to doPostBack
:
<a id="MainContent_LinkButtonWithClack1"
href="javascript:__doPostBack('ctl00$MainContent$LinkButtonWithClack1','Clack')">
Server then examines the contents of it and calls the Clack
event if it sees "Clack".
Of course you are unlikely to derive from LinkButton
, I'm only using it as an example because you did. You likely will be implementing a server control from scratch. When doing so, please bring all your knowledge on server control creation, or read up if you don't have one - you will need it.
As a side-note, this day it's easier to find help with asp.net mvc than with webforms, since the latter is older and less and less people are using it. If you have any say in technology choice at all I'd choose asp.net mvc over webforms for almost anything.