|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
PreRender event questionJust 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 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 Show quoteHide quote "Matt Jensen" <replytonewsgro***@microsoft.com> wrote in message news:O02aYKvBGHA.216@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 > 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 Show quoteHide quote "Matt Jensen" <replytonewsgro***@microsoft.com> wrote in message news:O02aYKvBGHA.216@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 >
Other interesting topics
Net runtime crash
Looping through a filtered GridView Single Login Problem converting a variable within a append document.forms string Arghh!!!! Button Not Firing. Losing data in a textbox on postback ASP.NET code to launch new browser session/window? Access is denied: 'Interop.ADODB' error - almost ready to jump off the balcony! Tags inside value field of appsettings in web.config Run IISRESET in an asp.net page? |
|||||||||||||||||||||||