Home All Groups Group Topic Archive Search About

Best way to create Page_PreRender in VB.Net

Author
17 Dec 2005 5:17 AM
windsurfing_stew
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

Author
17 Dec 2005 2:35 PM
Karl Seguin
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!



<windsurfing_s***@yahoo.com.au> wrote in message
Show quote
news:1134796673.080934.147310@g43g2000cwa.googlegroups.com...
> 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
>
Author
17 Dec 2005 10:26 PM
windsurfing_stew
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?
Author
17 Dec 2005 11:38 PM
albert braun
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

AddThis Social Bookmark Button