Hi Rick,
It took a few minutes for the penny to drop reading your reply, and now I
see what you mean, I don't need this.Load setting to anything in the forms
that inherit the base because that will call the PageLoadEvent method. In
my child forms I had that set to:
this.Load += new System.EventHandler(this.PageLoadEvent);
which of course would cause it to be called twice!
I took this line out, and voila, it only gets called once. The reason I
didn't spot it was that it appeared like it was only doing it for the form
that was initiated from the hyperlink because that was the only page that
generated dynamic controls, whereas the others only filled some labels up
text, so it only overwrote the second time around!
uh duh, I should have known that!
Thanks for your help!
Cheers
Colin
"Rick Strahl [MVP]" <rickstrahl@hotmail.com> wrote in message
news:OPUmL0NyDHA.3220@tk2msftngp13.phx.gbl...[color=blue]
> Hi Colin,
>
> Check the setting of AutoEventHookup on the page. If you're using[/color]
CodeBehind[color=blue]
> pages you generally don't want this as the CodeBehind page automatically
> generates the OnLoad() event hookup.
>
> Also if your form is inherited and your event hookups in the base class[/color]
(in[color=blue]
> InitializeComponent) you will end up hooking the eventhandler multiple[/color]
times[color=blue]
> and so it fires more than once. The solution there is to remove the OnLoad
> code manually in the implementation level of the form.
>
> +++ Rick ---
>
> --
>
> Rick Strahl
> West Wind Technologies
>
http://www.west-wind.com/
>
http://www.west-wind.com/webblog/
> ----------------------------------
> Making waves on the Web
>
>
> "Colin Basterfield" <colinbasterfield@hotmail.com> wrote in message
> news:uhIyQRNyDHA.2116@TK2MSFTNGP11.phx.gbl...[color=green]
> > Hi,
> >
> > Hmmm, a strange one for me, but hopefully not for others...
> >
> > I have a base page which has
> >
> > virtual protected void PageLoadEvent(object sender, System.EventArgs[/color][/color]
e){}[color=blue][color=green]
> >
> > In the Page_Load method I call this
> >
> > PageLoadEvent(sender, e);
> >
> > In all the forms that inherit from it I have a protected override of
> > PageLoadEvent method which does the necessary for that particular form,
> > nothing too complex there, what is strange however is that one of the[/color]
> forms[color=green]
> > which is a summary page has a datagrid which has hyperlinks in, and if I
> > click on one of these links it goes to a 'info breakdown page' driven by[/color][/color]
a[color=blue][color=green]
> > parameter. Although there is no Page_Load method in the 'info breakdown
> > page' as it is replaced by the PageLoadEvent method, this method gets[/color]
> called[color=green]
> > once independently, and then again through the base page Page_Load event
> > method.
> >
> > The way I proved this was to put a breakpoint in both the Page_Load[/color][/color]
event[color=blue]
> of[color=green]
> > the Base Page, and one in the 'info breakdown page' PageLoadEvent[/color][/color]
method.[color=blue][color=green]
> > So then I click the hyperlink on the summary page, and it immediately[/color]
> stops[color=green]
> > in PageLoadEvent on the 'info breakdown page', and then if you F5 it,[/color][/color]
it[color=blue][color=green]
> > stops in the base page Page_Load method code, which of course calls the
> > PageLoadEvent of the 'info breakdown page'.
> >
> > This isn't the case for the other pages, and there only difference is[/color][/color]
that[color=blue][color=green]
> > the 'info breakdown page' is accessed/initiated by a hyperlink.
> >
> > Any ideas anyone?
> > cheers in advance
> > Colin B
> >
> >[/color]
>
>[/color]