BUG: Init Function in a Visual C# Mobile Web Application Is Not Fired (309471)
The information in this article applies to:
- Microsoft Mobile Internet Toolkit (MMIT)
- Microsoft Visual C# .NET (2002)
This article was previously published under Q309471 SYMPTOMS
If you use the Properties window to create an Init event handler in a Visual C# .NET mobile Web application, the code in the handler is not executed because the handler is not called.
CAUSE
In Visual C# code-behind pages, control events are connected to delegates in the InitializeComponent function. The page's Init event executes this function. For the Init event of a child control (which includes all mobile controls, even the mobile Form control) to execute, the Init event must be connected to a delegate with an event handler. A child control's Init event handler must be executed before the page's Init event is executed. Because Microsoft Visual Studio .NET adds code to connect the event to a delegate of a child control's Init event in the InitializeComponent function, the child control's Init event does not execute because the event handler is executed after (and not before) the page's Init event.
RESOLUTION
To work around this problem, change the private modifier for the handler to Protected or Public after you create the handler in the code-behind page. Add a OnInit attribute to the control, and specify the name of the event handler as the value (for example, OnInit="Form1_Init").
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 8/11/2003 |
---|
Keywords: | kbbug kbide kbpending kbServerControls KB309471 |
---|
|