Which of the two techniques below is better and why? 1) Use a web page (aspx) and in it, in a server side container (let’s say a “runat=server” table cell) dynamically load a web user control (ascx) depending on what you want to do in a given time. 2) Use multiple
web pages (aspx) and load and uload them, depending on what you want to do in a given time. Thanks in advance for your help. Giorgos
From my experience I would say that it would probably be better to use multiple aspx pages that use design time user controls. I have found that dynamically loaded controls that cause post back can be problematic and hard to maintain. Because the page class
is rebuilt upon every request it has to be smart enough to know how to load all of the controls from its previous state before it can process the request. Therefore you must store the names of the controls in the view state so that you can reload them on the
next request. Once you start loading and unloading a lot of controls this can get difficult. Another problem I have seen with dynamically loaded user controls is that they can no longer depend on the Page.IsPostback property. When the control is loaded for
the first time on a post back from the hosting page, IsPostback returns true and there is no way to determine if this is the first time the control was loaded without using your own custom scheme such as storing information in the View State. I'm by no means
an expert so perhaps someone else knows a better solution to the problems I mentioned.
giorgos
Member
5 Points
1 Post
web forms vs web user controls
Aug 04, 2003 01:02 AM|LINK
jnesbitt
Member
59 Points
21 Posts
Re: web forms vs web user controls
Aug 04, 2003 03:20 PM|LINK