Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASPNET 3.0 newbie question

Reply
Thread Tools

ASPNET 3.0 newbie question

 
 
ckkwan@my-deja.com
Guest
Posts: n/a
 
      05-13-2008
My VS2008 just arrive.

One very dumb question, how to subscribe to event like Page_Init?

I can't find it anywhere in the IDE. Ended up have to type in myself.

TIA
 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      05-13-2008
If using VB, open your code-behind page in the IDE,
select (Page Events) from the left-hand dropdown,
and then select Init from the right-hand dropdown.

The IDE will write this :

Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

End Sub

If you are coding in C#, enter the Page_Init event handler using this code :

private void Page_Init(object sender, EventArgs e)

{

}

The IDE won't write anything for you.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> My VS2008 just arrive.
>
> One very dumb question, how to subscribe to event like Page_Init?
>
> I can't find it anywhere in the IDE. Ended up have to type in myself.
>
> TIA




 
Reply With Quote
 
 
 
 
Madhur
Guest
Posts: n/a
 
      05-13-2008
Just for the information , since you are newbie.

You might be wondering how this method definition is magically being linked
to Page's Init event, look at the directive
AutoEventWireUp

--
Madhur

"Juan T. Llibre" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> If using VB, open your code-behind page in the IDE,
> select (Page Events) from the left-hand dropdown,
> and then select Init from the right-hand dropdown.
>
> The IDE will write this :
>
> Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
> Handles Me.Init
>
> End Sub
>
> If you are coding in C#, enter the Page_Init event handler using this code
> :
>
> private void Page_Init(object sender, EventArgs e)
>
> {
>
> }
>
> The IDE won't write anything for you.
>
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaņol : http://asp.net.do/foros/
> ======================================
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> My VS2008 just arrive.
>>
>> One very dumb question, how to subscribe to event like Page_Init?
>>
>> I can't find it anywhere in the IDE. Ended up have to type in myself.
>>
>> TIA

>
>
>


 
Reply With Quote
 
sturyuu5eye@gmail.com
Guest
Posts: n/a
 
      05-16-2008
Precisely, I used to be able to do this in VS2003.

But now I am not able to do it anymore in VS2008

I just received my VS2008 last week.

On May 13, 10:36*pm, "Juan T. Llibre" <(E-Mail Removed)>
wrote:
> If using VB, open your code-behind page in the IDE,
> select (Page Events) from the left-hand dropdown,
> and then select Init from the right-hand dropdown.
>
> The IDE will write this :
>
> Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
>
> End Sub
>
> If you are coding in C#, enter the Page_Init event handler using this code :
>
> private void Page_Init(object sender, EventArgs e)
>
> {
>
> }
>
> The IDE won't write anything for you.
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ======================================
>
>
>
> <(E-Mail Removed)> wrote in messagenews:(E-Mail Removed)...
> > My VS2008 just arrive.

>
> > One very dumb question, how to subscribe to event like Page_Init?

>
> > I can't find it anywhere in the IDE. Ended up have to type in myself.

>
> > TIA- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
sturyuu5eye@gmail.com
Guest
Posts: n/a
 
      05-16-2008
Yes, I think the AutoEventWireUp is the clue.

And Since I jump from VS2003 to VS2008. I didn't aware something that
had changed since 2005.

It seems like it had been like this since VS2005. Where VB.NET can
select the object and event for page events, but in C# we have to
explicitly type the event handler method.


On May 14, 1:29*am, "Madhur" <(E-Mail Removed)> wrote:
> Just for the information , since you are newbie.
>
> You might be wondering how this method definition is magically being linked
> to Page's Init event, look at the directive
> AutoEventWireUp
>
> --
> Madhur
>
> "Juan T. Llibre" <(E-Mail Removed)> wrote in messagenews:(E-Mail Removed). ..

 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      05-16-2008
re:
!> Where VB.NET can select the object and event for page events,
!> but in C# we have to explicitly type the event handler method.

Here's the trick...

In both VS 2005 and VS2008 :

If you use inline code, whether C# or VB.NET, you don't have to type the event handler method.
If you use code-behind in C#, you do have to type the event handler method.
If you use code-behind in VB.NET, you don't have to type the event handler method.

In C#, if you configured <pages autoEventWireup , in web.config, to "true":


<system.web>
<pages autoEventWireup="true" />
</system.web>

and then, if you select an inline code page in a VS 2005/2008 C# project,
select "Page" from the dropdown "Server Objects and Events"
and select "Init" from the right-hand dropdown, the IDE writes this :

<script runat="server">
protected void Page_Init(object sender, EventArgs e)
{

}
</script>

If you select "place code in separate file" (code-behind),
neither of the 2005/2008 IDEs list the Page Events.

However, in both VS 2005 and 2008, when using VB.NET,
you don't need to set <pages autoEventWireup to "true"
in web.config in order to be able to select Events in the IDE.





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
Yes, I think the AutoEventWireUp is the clue.

And Since I jump from VS2003 to VS2008. I didn't aware something that
had changed since 2005.

It seems like it had been like this since VS2005. Where VB.NET can
select the object and event for page events, but in C# we have to
explicitly type the event handler method.


On May 14, 1:29 am, "Madhur" <(E-Mail Removed)> wrote:
> Just for the information , since you are newbie.
>
> You might be wondering how this method definition is magically being linked
> to Page's Init event, look at the directive
> AutoEventWireUp
>
> --
> Madhur
>
> "Juan T. Llibre" <(E-Mail Removed)> wrote in messagenews:(E-Mail Removed). ..





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is the aspnet account called "aspnet" for all non-English versions of Windows and IIS? torus@tpg.com.au ASP .Net 7 03-23-2007 04:00 AM
Upgrade from aspnet 1.1 to aspnet 2.0 Gary Nelson ASP .Net 2 10-14-2005 05:16 PM
microsoft.public.dotnet.framework.aspnet.webcontrols ,microsoft.public.dotnet.framework.aspnet Alfred Sehmueller ASP .Net Web Controls 0 02-20-2004 02:39 PM
ASPNET User ID - Newbie ?'s, apologies John ASP .Net Security 6 12-10-2003 06:46 PM
Restricting ASPNET ACLs without breaking ASPNET (newbie-ish) Brian Schuth ASP .Net Security 0 09-08-2003 06:09 PM



Advertisments