|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Best way to create Page_PreRender in VB.NetHi,
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 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 -- Show quoteHide quoteMY 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 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 > 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? 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
Other interesting topics
Session Question
start ASP net from very scratch ConnectionStrings in ASP.NET 2.0? Funny Error Client Side Checkbox Code Declaring an Enum that the whole project can use? Built-in controls with custom providers Custom membership provider problem Highlighting DropDownList Items Running client commands from asp.net app |
|||||||||||||||||||||||