473,473 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PreRender event question

Howdy all - and seasons greetings

Just wondering, I've recently discovered the PreRender event for .NET (both
for the page and for controls), which seems like a life saver for doing page
data loads that need to occur AFTER event handlers have fired, as well as
after page load and postback. Is this good, bad or common practice?

example

I've got a repeater on the page, and in the header of the repeater I've got
hyperlinks for sorting the repeater and dropdown lists for filtering it, and
therefore the repeater has (I think) to be bound AFTER the hyperlink-click
or dropdownlist-selection-change events, hence pre-render seems to be the
place.

Another case, in the 'job booking system' that I'm building, the job master
needs to be able to change between job master and job worker roles, hence a
role-changing dropdown list at the top of the page, and given the
DDL-selection change events I believe occur after page load, and given in my
case databinding needs to happen after pageload, postback, and after
DDL-selection-change events, PreRender seems to be the ONLY place I can use.
However I've really not seen much about the PreRender event, although there
seems to be a bit around if you're actually searching on the term PreRender.
So I'm slightly hesitant about using it just yet...

Would appreciate any thoughts

Cheers
Matt
Dec 22 '05 #1
3 8089
Matt,

Technically, you can databind in PreRender. But...

This event is the last stop before the page gets sent to the client. At this
stage it is already supposed to be fully bound, built, etc. You can do some
format changes, calculations, set final values of the page. That is what the
event for. Databinding here is out of place.

I seem to make difference between a page load and a postback. There is no
such a difference. A postback causes Page_Load event.

True, all change events handlers get called after Page_Load. But you don't
have to wait until the change event handler runs. Already in Page_Load event
you can read all control values, including the current selection of the
dlls. I use this approach in my programs. I hardly use any change events. It
is enough if you set AutoPostback=true, then any change will cause a
postback which will trigger Page_Load event in which you can read current
values of the ddls.

Eliyahu

"Matt Jensen" <re***************@microsoft.com> wrote in message
news:O0*************@TK2MSFTNGP15.phx.gbl...
Howdy all - and seasons greetings

Just wondering, I've recently discovered the PreRender event for .NET
(both for the page and for controls), which seems like a life saver for
doing page data loads that need to occur AFTER event handlers have fired,
as well as after page load and postback. Is this good, bad or common
practice?

example

I've got a repeater on the page, and in the header of the repeater I've
got hyperlinks for sorting the repeater and dropdown lists for filtering
it, and therefore the repeater has (I think) to be bound AFTER the
hyperlink-click or dropdownlist-selection-change events, hence pre-render
seems to be the place.

Another case, in the 'job booking system' that I'm building, the job
master needs to be able to change between job master and job worker roles,
hence a role-changing dropdown list at the top of the page, and given the
DDL-selection change events I believe occur after page load, and given in
my case databinding needs to happen after pageload, postback, and after
DDL-selection-change events, PreRender seems to be the ONLY place I can
use. However I've really not seen much about the PreRender event, although
there seems to be a bit around if you're actually searching on the term
PreRender. So I'm slightly hesitant about using it just yet...

Would appreciate any thoughts

Cheers
Matt

Dec 22 '05 #2
Why don't you bound your datas directly into your events handlers ?

Dec 22 '05 #3
Matt, i use PreRender is a similar fashion...not necessarily with binding,
but I could see that happening.

I have an user control which display an article information. The articleId
is passed in as a property. I'm linkbuttons to select which article to
display. My user control can't load the details in Page_Load because
that'll fire before my linkbutton's eventhandler has gone off. Instead, i
use prerender to fetch the article based on the passed in id and set a bunch
of Text properties.

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Matt Jensen" <re***************@microsoft.com> wrote in message
news:O0*************@TK2MSFTNGP15.phx.gbl...
Howdy all - and seasons greetings

Just wondering, I've recently discovered the PreRender event for .NET
(both for the page and for controls), which seems like a life saver for
doing page data loads that need to occur AFTER event handlers have fired,
as well as after page load and postback. Is this good, bad or common
practice?

example

I've got a repeater on the page, and in the header of the repeater I've
got hyperlinks for sorting the repeater and dropdown lists for filtering
it, and therefore the repeater has (I think) to be bound AFTER the
hyperlink-click or dropdownlist-selection-change events, hence pre-render
seems to be the place.

Another case, in the 'job booking system' that I'm building, the job
master needs to be able to change between job master and job worker roles,
hence a role-changing dropdown list at the top of the page, and given the
DDL-selection change events I believe occur after page load, and given in
my case databinding needs to happen after pageload, postback, and after
DDL-selection-change events, PreRender seems to be the ONLY place I can
use. However I've really not seen much about the PreRender event, although
there seems to be a bit around if you're actually searching on the term
PreRender. So I'm slightly hesitant about using it just yet...

Would appreciate any thoughts

Cheers
Matt

Dec 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alireza Ziai | last post by:
I have problem with prerender event in my page I dont know why prerender event occurs immediatley after Load event , I have same problem with Unload event too ,is it a problem with framework or sth ?
1
by: DalePres | last post by:
Does anyone know if there is a known bug or workaround, or other solution to this problem? I have a page with several imagebutton server controls and needed to handle the PreRender event in C#....
0
by: wardy | last post by:
I've got a .NET web application running in .NET 1.1 on IIS 5 with SQL Server 2000. I've noticed that at times the page rendering is delayed, and when I run the trace I see that the begin prerender...
7
by: wardy | last post by:
Hi, I'm hoping someone can lend me a hand....I've got a .NET Web app running on Windows 2000 IIS 5.0 linking to a SQL Server 2000 database. When the database is located on the same server as the...
0
by: Selden McCabe | last post by:
I have a base page class, from which all pages in my project inherit. In the base page prerender event, I would like to know which page is being loaded. But when I do this.ID, it return null. ...
3
by: John Scott | last post by:
Hey I've got an odd problem here. I have two user controls on a single page. Here is the flow of my page Page(OnLoad) UC1(OnPreRender) UC2(OnPreRender) Page(ButtonClick) UC1(OnPreRender)...
2
by: Joe | last post by:
Hello All: I have been bitten a few times lately as I've tried to implement functionality in the Page_PreRender event. So here is my question: for what purpose do you use the PreRender event?...
2
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
i'm not sure how the preRender event gets handled. if i have a function: protected void tbPasswordPreRender(object sender, EventArgs e) { tbPswd1.Attributes = tbPswd1.Text; tbPswd2.Attributes...
0
by: tshad | last post by:
In VS 2008, I have 2 pages, one aspx page and one ascx page. The PreRender event is not firing on the Contol page. The aspx page starts out: <%@ Page Language="VB" AutoEventWireup="true"...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.