473,385 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

is this a hack?

Hi
I commonly have the problem that given a page with 2+ usercontrols
many of the pages events occur before the childs, e.g. PageLoad, because
of this I wind up moving code from PageLoad to PreRender. This doesn't
feel right.

More info:
(1) I put code in Page_Load in the usercontrols so that all the ViewState
and other stuff has loaded in
(2) I put code in PreRender in the parent because of this
(3) Given a page with a usercontrol(1) which itself holds a UserControl(2) then
as the PreRender for the UserControl happens second then I could wind up
with Control2 having code in PageLoad, Control1 having code in PreRender
and the page having code in Render to ensure the right loading order

To get around this I've though of making a class that takes as arguments
a number of events, e.g. the Page_Loads of the child UserControls,
and once all of these have fired it calls some other event,
e.g. Page_Load2, of the parent.
This feels like a solution that will work but possibly still not
the best way of doing things. The page itself could also do this
but thats more of less the same thing.

Any feedback? Are there any asp.net patterns about the place?

Ta
F
Nov 18 '05 #1
2 1149
Well, you are correct about it not feeling right. You need to examine how
you are reloading your controls when a postback occurs. First off, make sure
that you are checking to see if this is a postback using Page.IsPostBack.
Secondly, you need to reload your controls in EXACTLY the same order,
everytime, so that the ASP.NET runtime can recreate the control tree
accurately. Then, events should fire in the proper order.

HTH,

Kyril
<fo******@yahoo.co.uk> wrote in message
news:ac**************************@posting.google.c om...
Hi
I commonly have the problem that given a page with 2+ usercontrols
many of the pages events occur before the childs, e.g. PageLoad, because
of this I wind up moving code from PageLoad to PreRender. This doesn't
feel right.

More info:
(1) I put code in Page_Load in the usercontrols so that all the ViewState
and other stuff has loaded in
(2) I put code in PreRender in the parent because of this
(3) Given a page with a usercontrol(1) which itself holds a UserControl(2)
then
as the PreRender for the UserControl happens second then I could wind up
with Control2 having code in PageLoad, Control1 having code in PreRender
and the page having code in Render to ensure the right loading order

To get around this I've though of making a class that takes as arguments
a number of events, e.g. the Page_Loads of the child UserControls,
and once all of these have fired it calls some other event,
e.g. Page_Load2, of the parent.
This feels like a solution that will work but possibly still not
the best way of doing things. The page itself could also do this
but thats more of less the same thing.

Any feedback? Are there any asp.net patterns about the place?

Ta
F

Nov 18 '05 #2
> Then, events should fire in the proper order.

That is the proper order. The OnInit and Render events occur for the
parent first, see
http://groups.google.co.uk/groups?hl...TF-8%26hl%3Den

The problem is that isn't what I want to occur, I want the child
events to
occur after the parent events.
Nov 18 '05 #3

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

Similar topics

3
by: Haines Brown | last post by:
I thought I had understood this issue and implemented a work around, but now when I check on IE5, it is not working: ... #IE-hack { margin-left: auto; margin-right: auto; width: 20em;...
3
by: cr88192 | last post by:
for various reasons, I added an imo ugly hack to my xml parser. basically, I wanted the ability to have binary payload within the xml parse trees. this was partly because I came up with a binary...
11
by: Chris Beall | last post by:
Here's the problem: http://pages.prodigy.net/chris_beall/Demo/theproblem.html The page contains inline text, then some additional pairs of text which are floated right and left. (This is a...
2
by: Ing. Rajesh Kumar | last post by:
Hi everybody I have about 50 code behind *.vb files from which i have created a single *.dll file. This single *.dll file and all the *.aspx files i will put on a clients computer. So i just...
5
by: Nmx | last post by:
Hi everyone, I'm writing a patch to a search engine (aspseek http://www.aspseek.org/) compile under gcc 3.4.4 on FC3. At some point, I found this piece of code: -- // Dirty hack to avoid...
0
by: Xah Lee | last post by:
In this article, i explain how the use of bit masks is a hack in many imperative languages. Often, a function will need to take many True/False parameters. For example, suppose i have a function...
12
by: Ivo | last post by:
I am programming forum. Tech is ASP.NET, C# and SQL Server 2005. I want to see is my site safe, have I made some security problems. Can you try to hack my site untill 10-september-2007.:...
7
by: badc0de4 | last post by:
Is this a stupid hack or a clever hack? Is it a "hack" at all? ==================== #include <stdio.h> /* !!HACK!! */ /* no parenthesis on the #define'd expression */ #define...
11
by: howa | last post by:
... width:202px; *width:200px; ... The setting with * only can be read by IE, but I want to know... 1. What is the name of this hack? 2. Is all attribute can be combined with a star so only...
0
by: freehackers | last post by:
FreeHackers Group : Only 6 Steps to get cracked your target password 1- Fill in the E-Mail Cracking order form , to the best of your knowledge “contact us to freehackers.007gmail.com with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.