browse: forums | FAQ
Connecting Tech Pros Worldwide

Hey there! Do you need C# / C Sharp help?

Get answers from our community of C# / C Sharp experts on BYTES! It's free.

overloading ASP.NET intrinsic event handler methods

John A Grandy
Guest
 
Posts: n/a
#1: Apr 18 '06
For ASP.NET UserControls , is it possible to provide multiple overrides of
the intrinsic handler methods (those for which the delegate that wires the
event to the handler is built-in , such as Init , Load , PreRender ,
Render ) ... ?

I need to create various .ascx controls on-the-fly , calling Init() methods
with different signatures ...

I think the syntax might be :

new public void Init(int param1)
{
Init(param1,string.Empty);
}

new public void Init(int param1, string param2)
{
....
....
}

And the intrisic Init() handler method (which has no params) need not be
explicitly specified.







Jeffrey Hornby
Guest
 
Posts: n/a
#2: Apr 19 '06

re: overloading ASP.NET intrinsic event handler methods


For events like Init, Load and PreRender, you can add a handler like this:

Page.Load += new EventHandler(Load_Method);

Note that every event handler has a particular signature. For the load
method it's:
Load_Method(object sender, EventArgs e)

For methods you can subclass the control and add an event handler to the new
control. From the method you can raise the new event.



"John A Grandy" wrote:
[color=blue]
> For ASP.NET UserControls , is it possible to provide multiple overrides of
> the intrinsic handler methods (those for which the delegate that wires the
> event to the handler is built-in , such as Init , Load , PreRender ,
> Render ) ... ?
>
> I need to create various .ascx controls on-the-fly , calling Init() methods
> with different signatures ...
>
> I think the syntax might be :
>
> new public void Init(int param1)
> {
> Init(param1,string.Empty);
> }
>
> new public void Init(int param1, string param2)
> {
> ....
> ....
> }
>
> And the intrisic Init() handler method (which has no params) need not be
> explicitly specified.
>
>
>
>
>[/color]
John A Grandy
Guest
 
Posts: n/a
#3: Apr 21 '06

re: overloading ASP.NET intrinsic event handler methods


So for intrinsic events (Init, Load, PreRender) etc. , every EventHandler
delegate you add will have its method triggerred when the event fires ? I
assume they trigger in the order in which they were added to the event.

"Jeffrey Hornby" <JeffreyHornby@discussions.microsoft.com> wrote in message
news:7CEA1615-446F-4F98-944C-B20DD7115CE3@microsoft.com...[color=blue]
> For events like Init, Load and PreRender, you can add a handler like this:
>
> Page.Load += new EventHandler(Load_Method);
>
> Note that every event handler has a particular signature. For the load
> method it's:
> Load_Method(object sender, EventArgs e)
>
> For methods you can subclass the control and add an event handler to the
> new
> control. From the method you can raise the new event.
>
>
>
> "John A Grandy" wrote:
>[color=green]
>> For ASP.NET UserControls , is it possible to provide multiple overrides
>> of
>> the intrinsic handler methods (those for which the delegate that wires
>> the
>> event to the handler is built-in , such as Init , Load , PreRender ,
>> Render ) ... ?
>>
>> I need to create various .ascx controls on-the-fly , calling Init()
>> methods
>> with different signatures ...
>>
>> I think the syntax might be :
>>
>> new public void Init(int param1)
>> {
>> Init(param1,string.Empty);
>> }
>>
>> new public void Init(int param1, string param2)
>> {
>> ....
>> ....
>> }
>>
>> And the intrisic Init() handler method (which has no params) need not be
>> explicitly specified.
>>
>>
>>
>>
>>[/color][/color]


Closed Thread