ASPNET 3.0 newbie question

Discussion in 'ASP .Net' started by ckkwan@my-deja.com, May 13, 2008.

  1. Guest

    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
     
    , May 13, 2008
    #1
    1. Advertising

  2. 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/
    ======================================
    <> wrote in message news:...
    > 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
     
    Juan T. Llibre, May 13, 2008
    #2
    1. Advertising

  3. Madhur Guest

    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" <> wrote in message
    news:...
    > 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/
    > ======================================
    > <> wrote in message
    > news:...
    >> 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

    >
    >
    >
     
    Madhur, May 13, 2008
    #3
  4. Guest

    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" <>
    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/
    > ======================================
    >
    >
    >
    > <> wrote in messagenews:...
    > > 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 -
     
    , May 16, 2008
    #4
  5. Guest

    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" <> 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" <> wrote in messagenews:...
     
    , May 16, 2008
    #5
  6. 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/
    ======================================
    <> wrote in message news:...
    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" <> 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" <> wrote in messagenews:...
     
    Juan T. Llibre, May 16, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gary Nelson

    Upgrade from aspnet 1.1 to aspnet 2.0

    Gary Nelson, Oct 14, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    496
    Gary Nelson
    Oct 14, 2005
  2. Replies:
    7
    Views:
    673
    Juan T. Llibre
    Mar 23, 2007
  3. Brian Schuth
    Replies:
    0
    Views:
    286
    Brian Schuth
    Sep 8, 2003
  4. John

    ASPNET User ID - Newbie ?'s, apologies

    John, Dec 9, 2003, in forum: ASP .Net Security
    Replies:
    6
    Views:
    182
    Holly Mazerolle
    Dec 10, 2003
  5. Alfred Sehmueller
    Replies:
    0
    Views:
    274
    Alfred Sehmueller
    Feb 20, 2004
Loading...

Share This Page