does it still apply in 2.0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,
i was wondering if the following code snippet from a 1.1 exerpt still apply
in asp.net 2.0 framework:

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
BubbleControl.BubbleClick += new EventHandler(WebForm1_BubbleClick);
}
#endregion

thanks,
rodchar
 
Yes it would work as-is, however VS2005 doesn't use it because in ASP.NET
2.0 / VS2005 you can wire event handlers without touching the exact
code-behind file (thanks to partial classes).
 
so where could i put the contents of InitializeComponent() with regards to
the partial class model?
 
Note that what I meant is that it's not used at all anymore. You can write
it manually like that into code-behind if you like

E.g With VS2005 you could to add it manually in case you intent to use it.
The VS2005's ways are either just writing the handler in code or
double-click the control in design view (or select the event from property
browser and click it) to force it to generate the event handler. VS2005
would generate them in C# as attributes to the controls. E.g if you have a
Button on Page

<asp:Button ID="Button1" runat="server" Text="Click me" />

Double clicking the control on designer view would add
OnClick="Button1_Click" to the Button's tag and add protected method to
code-behind or inline code (depending on which model you use)


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
 
Back
Top