does it still apply in 2.0

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
 
T

Teemu Keiski

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).
 
G

Guest

so where could i put the contents of InitializeComponent() with regards to
the partial class model?
 
T

Teemu Keiski

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top