Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Best way to create Page_PreRender in VB.Net

Reply
Thread Tools

Best way to create Page_PreRender in VB.Net

 
 
windsurfing_stew@yahoo.com.au
Guest
Posts: n/a
 
      12-17-2005
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

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      12-17-2005
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!



<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.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
>



 
Reply With Quote
 
 
 
 
windsurfing_stew@yahoo.com.au
Guest
Posts: n/a
 
      12-17-2005
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?

 
Reply With Quote
 
albert braun
Guest
Posts: n/a
 
      12-17-2005
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

 
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
Best practices around "Page_PreRender" and "Page_Load" events Max2006 ASP .Net 7 07-31-2007 12:37 PM
page_prerender Ashish ASP .Net 1 09-25-2004 04:59 AM
Page_Prerender Ashish ASP .Net 0 09-24-2004 01:06 PM
Can EventHandler fire in Page_PreRender event? TPS ASP .Net 2 08-06-2004 02:58 PM
OnClick Handler for Buttons added During Page_PreRender? How? Sky Sigal ASP .Net 0 08-03-2004 07:16 PM



Advertisments