Best way to create Page_PreRender in VB.Net

Discussion in 'ASP .Net' started by windsurfing_stew@yahoo.com.au, Dec 17, 2005.

  1. Guest

    Hi,

    Quick question. What's the best way to create the handler for
    Page_Prerender in ASP.Net 2.0. I used to just use the dropdowns to
    select (Page Events) on the left and choose PreRender in the right hand
    dropdown. Now however these are not listed.

    Any recommendations?

    Stew
    , Dec 17, 2005
    #1
    1. Advertising

  2. Karl Seguin Guest

    In vb.net there's always three ways to implement a base method. There are
    some minor diferences between then (not functionality though). I'd pick the
    one the most consistant with how you do it within the rest of your system.

    1 - (the way I guess you probably want it)
    Protected Sub Page_PreRender(ByVal s As Object, ByVal e As EventArgs)
    Handles Me.PreRender
    'code here
    End Sub


    2 -
    Protected Overrides Sub onPreRender(ByVal e As System.EventArgs)
    'code here
    MyBase.OnPreRender(e)
    End Sub


    3 -
    'put this in Init or somwhere
    AddHandler Me.PreRender, AddressOf Page_PreRender2

    Protected Sub Page_PreRender2(ByVal sender As Object, ByVal e As
    System.EventArgs)
    'code here
    End Sub

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    <> wrote in message
    news:...
    > Hi,
    >
    > Quick question. What's the best way to create the handler for
    > Page_Prerender in ASP.Net 2.0. I used to just use the dropdowns to
    > select (Page Events) on the left and choose PreRender in the right hand
    > dropdown. Now however these are not listed.
    >
    > Any recommendations?
    >
    > Stew
    >
    Karl Seguin, Dec 17, 2005
    #2
    1. Advertising

  3. Guest

    Hi Karl,

    Thanks for your response. I was actually more interested in how you do
    this through the IDE. I used to be able to create handlers like
    Page_PreRender by using the two dropdowns above the code.

    Thoughts?
    , Dec 17, 2005
    #3
  4. albert braun Guest

    Stew,

    Maybe you want the TAB complete functionality in VS.NET ?

    Inside your page's Page_Load method, you can type:

    this.PreRender +=

    and then you should see Intellisense telling you to hit the TAB key for
    autocomplete functionality. You hit TAB the first time and it completes
    your statement by appending:

    new EventHandler(_Default_PreRender);

    Then, you hit TAB a second time, and the IDE inserts a new
    corresponding method body below:

    void _Default_PreRender(object sender, EventArgs e)
    {
    throw new Exception("The method or operation is not
    implemented.");
    }

    Then you just replace the Exception throwing statement with your
    desired code.
    (Note: in this case, my page class is named _Default, so your method
    name may vary).

    Hope that helps.

    Regards,
    Albert Braun
    albert braun, Dec 17, 2005
    #4
    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. Ashish

    Page_Prerender

    Ashish, Sep 24, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    496
    Ashish
    Sep 24, 2004
  2. Ashish

    page_prerender

    Ashish, Sep 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,866
    Jonathan Allen
    Sep 25, 2004
  3. Sky Sigal
    Replies:
    0
    Views:
    360
    Sky Sigal
    Aug 3, 2004
  4. TPS
    Replies:
    2
    Views:
    3,530
  5. Max2006
    Replies:
    7
    Views:
    819
    ThunderMusic
    Jul 31, 2007
Loading...

Share This Page