By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 941 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Init event for control doesn't fire

P: n/a
I have Panel control on the page. I am handling Init event for it. It
doesn't seem to fire at all. Why?
Thank you
Shimon.
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
How are you registering for the Init event?

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have Panel control on the page. I am handling Init event for it. It
doesn't seem to fire at all. Why?
Thank you
Shimon.


Nov 19 '05 #2

P: n/a
Like this. All of them fire except for Init
#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

this.Betterpanel2.Load += new System.EventHandler(this.Betterpanel2_Load);

this.Betterpanel2.Unload += new
System.EventHandler(this.Betterpanel2_Unload);

this.Betterpanel2.PreRender += new
System.EventHandler(this.Betterpanel2_PreRender);

this.Betterpanel2.Init += new System.EventHandler(this.Betterpanel2_Init);

this.Betterpanel2.Disposed += new
System.EventHandler(this.Betterpanel2_Disposed);

InitializeComponent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{
this.Disposed += new
System.EventHandler(this.CompositeControlTest_Disp osed);

this.Unload += new System.EventHandler(this.CompositeControlTest_Unlo ad);

this.Load += new System.EventHandler(this.Page_Load);

this.Init += new System.EventHandler(this.CompositeControlTest_Init );

this.PreRender += new
System.EventHandler(this.CompositeControlTest_PreR ender);

}

#endregion

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
How are you registering for the Init event?

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have Panel control on the page. I am handling Init event for it. It
doesn't seem to fire at all. Why?
Thank you
Shimon.


Nov 19 '05 #3

P: n/a
Well, that explains it :)

Child controls' OnInit is called before the Page's OnInit. You're registering
for the events too late. You can put <asp:Panel OnInit="MyEventHandler" ...
/> into the ASP directly and that will register your event handler when the
contol is created.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Like this. All of them fire except for Init
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

this.Betterpanel2.Load += new
System.EventHandler(this.Betterpanel2_Load);

this.Betterpanel2.Unload += new
System.EventHandler(this.Betterpanel2_Unload);

this.Betterpanel2.PreRender += new
System.EventHandler(this.Betterpanel2_PreRender);

this.Betterpanel2.Init += new
System.EventHandler(this.Betterpanel2_Init);

this.Betterpanel2.Disposed += new
System.EventHandler(this.Betterpanel2_Disposed);

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Disposed += new
System.EventHandler(this.CompositeControlTest_Disp osed);

this.Unload += new
System.EventHandler(this.CompositeControlTest_Unlo ad);

this.Load += new System.EventHandler(this.Page_Load);

this.Init += new System.EventHandler(this.CompositeControlTest_Init );

this.PreRender += new
System.EventHandler(this.CompositeControlTest_PreR ender);

}

#endregion

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
How are you registering for the Init event?

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have Panel control on the page. I am handling Init event for it.
It
doesn't seem to fire at all. Why?
Thank you
Shimon.


Nov 19 '05 #4

P: n/a
Thanks for Brock's Great explanation and suggestions.

Hi Shimon,

Like Brock has mentioned, the OnInit event of the Page is too late for
registering event handler for sub control(added statically)'s Init event).
Because all the static sub control's Init event is fired when they are
being added into the parent container which is before the Page's OnInit
function. You can try using Brock's suggetion on registering the event
handler in aspx page inline.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Message-ID: <11***********************@msnews.microsoft.com>
| From: Brock Allen <ba****@NOSPAMdevelop.com>
| Subject: Re: Init event for control doesn't fire
| References: <ew**************@TK2MSFTNGP09.phx.gbl>
| Mime-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Reader 469.1
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Date: Fri, 12 Aug 2005 14:09:39 -0700
| NNTP-Posting-Host: c-66-30-185-175.hsd1.ma.comcast.net 66.30.185.175
| Lines: 1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:117757
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Well, that explains it :)
|
| Child controls' OnInit is called before the Page's OnInit. You're
registering
| for the events too late. You can put <asp:Panel OnInit="MyEventHandler"
...
| /> into the ASP directly and that will register your event handler when
the
| contol is created.
|
| -Brock
| DevelopMentor
| http://staff.develop.com/ballen
|
|
|
| > Like this. All of them fire except for Init
| > #region Web Form Designer generated code
| > override protected void OnInit(EventArgs e)
| >
| > {
| >
| > //
| >
| > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| >
| > //
| >
| > this.Betterpanel2.Load += new
| > System.EventHandler(this.Betterpanel2_Load);
| >
| > this.Betterpanel2.Unload += new
| > System.EventHandler(this.Betterpanel2_Unload);
| >
| > this.Betterpanel2.PreRender += new
| > System.EventHandler(this.Betterpanel2_PreRender);
| >
| > this.Betterpanel2.Init += new
| > System.EventHandler(this.Betterpanel2_Init);
| >
| > this.Betterpanel2.Disposed += new
| > System.EventHandler(this.Betterpanel2_Disposed);
| >
| > InitializeComponent();
| >
| > base.OnInit(e);
| >
| > }
| >
| > /// <summary>
| >
| > /// Required method for Designer support - do not modify
| >
| > /// the contents of this method with the code editor.
| >
| > /// </summary>
| >
| > private void InitializeComponent()
| >
| > {
| >
| > this.Disposed += new
| > System.EventHandler(this.CompositeControlTest_Disp osed);
| >
| > this.Unload += new
| > System.EventHandler(this.CompositeControlTest_Unlo ad);
| >
| > this.Load += new System.EventHandler(this.Page_Load);
| >
| > this.Init += new System.EventHandler(this.CompositeControlTest_Init );
| >
| > this.PreRender += new
| > System.EventHandler(this.CompositeControlTest_PreR ender);
| >
| > }
| >
| > #endregion
| >
| > "Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
| > news:11***********************@msnews.microsoft.co m...
| >
| >> How are you registering for the Init event?
| >>
| >> -Brock
| >> DevelopMentor
| >> http://staff.develop.com/ballen
| >>> I have Panel control on the page. I am handling Init event for it.
| >>> It
| >>> doesn't seem to fire at all. Why?
| >>> Thank you
| >>> Shimon.
|

|
|

Nov 19 '05 #5

P: n/a
Thank a lot Brock and Steven.
I should have figured out the answer.
Shimon.
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:vD*************@TK2MSFTNGXA01.phx.gbl...
Thanks for Brock's Great explanation and suggestions.

Hi Shimon,

Like Brock has mentioned, the OnInit event of the Page is too late for
registering event handler for sub control(added statically)'s Init event).
Because all the static sub control's Init event is fired when they are
being added into the parent container which is before the Page's OnInit
function. You can try using Brock's suggetion on registering the event
handler in aspx page inline.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Message-ID: <11***********************@msnews.microsoft.com>
| From: Brock Allen <ba****@NOSPAMdevelop.com>
| Subject: Re: Init event for control doesn't fire
| References: <ew**************@TK2MSFTNGP09.phx.gbl>
| Mime-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Reader 469.1
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Date: Fri, 12 Aug 2005 14:09:39 -0700
| NNTP-Posting-Host: c-66-30-185-175.hsd1.ma.comcast.net 66.30.185.175
| Lines: 1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:117757
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Well, that explains it :)
|
| Child controls' OnInit is called before the Page's OnInit. You're
registering
| for the events too late. You can put <asp:Panel OnInit="MyEventHandler"
..
| /> into the ASP directly and that will register your event handler when
the
| contol is created.
|
| -Brock
| DevelopMentor
| http://staff.develop.com/ballen
|
|
|
| > Like this. All of them fire except for Init
| > #region Web Form Designer generated code
| > override protected void OnInit(EventArgs e)
| >
| > {
| >
| > //
| >
| > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| >
| > //
| >
| > this.Betterpanel2.Load += new
| > System.EventHandler(this.Betterpanel2_Load);
| >
| > this.Betterpanel2.Unload += new
| > System.EventHandler(this.Betterpanel2_Unload);
| >
| > this.Betterpanel2.PreRender += new
| > System.EventHandler(this.Betterpanel2_PreRender);
| >
| > this.Betterpanel2.Init += new
| > System.EventHandler(this.Betterpanel2_Init);
| >
| > this.Betterpanel2.Disposed += new
| > System.EventHandler(this.Betterpanel2_Disposed);
| >
| > InitializeComponent();
| >
| > base.OnInit(e);
| >
| > }
| >
| > /// <summary>
| >
| > /// Required method for Designer support - do not modify
| >
| > /// the contents of this method with the code editor.
| >
| > /// </summary>
| >
| > private void InitializeComponent()
| >
| > {
| >
| > this.Disposed += new
| > System.EventHandler(this.CompositeControlTest_Disp osed);
| >
| > this.Unload += new
| > System.EventHandler(this.CompositeControlTest_Unlo ad);
| >
| > this.Load += new System.EventHandler(this.Page_Load);
| >
| > this.Init += new System.EventHandler(this.CompositeControlTest_Init );
| >
| > this.PreRender += new
| > System.EventHandler(this.CompositeControlTest_PreR ender);
| >
| > }
| >
| > #endregion
| >
| > "Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
| > news:11***********************@msnews.microsoft.co m...
| >
| >> How are you registering for the Init event?
| >>
| >> -Brock
| >> DevelopMentor
| >> http://staff.develop.com/ballen
| >>> I have Panel control on the page. I am handling Init event for it.
| >>> It
| >>> doesn't seem to fire at all. Why?
| >>> Thank you
| >>> Shimon.
|

|
|

Nov 19 '05 #6

P: n/a
You're welcome Shimon,

Always feel free to post here if there are anything we can help you.
Have a good day!

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Shimon Sim" <sh**********@community.nospam>
| References: <ew**************@TK2MSFTNGP09.phx.gbl>
<11***********************@msnews.microsoft.com>
<vD*************@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: Init event for control doesn't fire
| Date: Tue, 16 Aug 2005 09:18:12 -0400
| Lines: 146
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <#B**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:118236
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thank a lot Brock and Steven.
| I should have figured out the answer.
| Shimon.
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:vD*************@TK2MSFTNGXA01.phx.gbl...
| > Thanks for Brock's Great explanation and suggestions.
| >
| > Hi Shimon,
| >
| > Like Brock has mentioned, the OnInit event of the Page is too late for
| > registering event handler for sub control(added statically)'s Init
event).
| > Because all the static sub control's Init event is fired when they are
| > being added into the parent container which is before the Page's OnInit
| > function. You can try using Brock's suggetion on registering the event
| > handler in aspx page inline.
| >
| > Thanks & Regards,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| > --------------------
| > | Message-ID: <11***********************@msnews.microsoft.com>
| > | From: Brock Allen <ba****@NOSPAMdevelop.com>
| > | Subject: Re: Init event for control doesn't fire
| > | References: <ew**************@TK2MSFTNGP09.phx.gbl>
| > | Mime-Version: 1.0
| > | Content-Transfer-Encoding: 8bit
| > | Content-Type: text/plain; charset=iso-8859-1; format=flowed
| > | X-Newsreader: JetBrains Omea Reader 469.1
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | Date: Fri, 12 Aug 2005 14:09:39 -0700
| > | NNTP-Posting-Host: c-66-30-185-175.hsd1.ma.comcast.net 66.30.185.175
| > | Lines: 1
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:117757
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Well, that explains it :)
| > |
| > | Child controls' OnInit is called before the Page's OnInit. You're
| > registering
| > | for the events too late. You can put <asp:Panel
OnInit="MyEventHandler"
| > ..
| > | /> into the ASP directly and that will register your event handler
when
| > the
| > | contol is created.
| > |
| > | -Brock
| > | DevelopMentor
| > | http://staff.develop.com/ballen
| > |
| > |
| > |
| > | > Like this. All of them fire except for Init
| > | > #region Web Form Designer generated code
| > | > override protected void OnInit(EventArgs e)
| > | >
| > | > {
| > | >
| > | > //
| > | >
| > | > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
| > | >
| > | > //
| > | >
| > | > this.Betterpanel2.Load += new
| > | > System.EventHandler(this.Betterpanel2_Load);
| > | >
| > | > this.Betterpanel2.Unload += new
| > | > System.EventHandler(this.Betterpanel2_Unload);
| > | >
| > | > this.Betterpanel2.PreRender += new
| > | > System.EventHandler(this.Betterpanel2_PreRender);
| > | >
| > | > this.Betterpanel2.Init += new
| > | > System.EventHandler(this.Betterpanel2_Init);
| > | >
| > | > this.Betterpanel2.Disposed += new
| > | > System.EventHandler(this.Betterpanel2_Disposed);
| > | >
| > | > InitializeComponent();
| > | >
| > | > base.OnInit(e);
| > | >
| > | > }
| > | >
| > | > /// <summary>
| > | >
| > | > /// Required method for Designer support - do not modify
| > | >
| > | > /// the contents of this method with the code editor.
| > | >
| > | > /// </summary>
| > | >
| > | > private void InitializeComponent()
| > | >
| > | > {
| > | >
| > | > this.Disposed += new
| > | > System.EventHandler(this.CompositeControlTest_Disp osed);
| > | >
| > | > this.Unload += new
| > | > System.EventHandler(this.CompositeControlTest_Unlo ad);
| > | >
| > | > this.Load += new System.EventHandler(this.Page_Load);
| > | >
| > | > this.Init += new
System.EventHandler(this.CompositeControlTest_Init );
| > | >
| > | > this.PreRender += new
| > | > System.EventHandler(this.CompositeControlTest_PreR ender);
| > | >
| > | > }
| > | >
| > | > #endregion
| > | >
| > | > "Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
| > | > news:11***********************@msnews.microsoft.co m...
| > | >
| > | >> How are you registering for the Init event?
| > | >>
| > | >> -Brock
| > | >> DevelopMentor
| > | >> http://staff.develop.com/ballen
| > | >>> I have Panel control on the page. I am handling Init event for it.
| > | >>> It
| > | >>> doesn't seem to fire at all. Why?
| > | >>> Thank you
| > | >>> Shimon.
| > |
| >
| > |
| > |
| >
|
|
|

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.