473,233 Members | 1,703 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,233 software developers and data experts.

A better workaround?


A framework issue rather than a pure C# issue, so a little off topic,
but the aspnet.webcontrols group is very quiet, and people here seem
more experienced:

I came across an irritating problem with the ASP.NET execution model
about which I've seen several people ask questions but have seen few
good answers.

The exact details are not really important, but to give you an idea, I
need to provide a set of arbitrary page designs associated with
particular combinations of entries in a directory structure. As the user
browses the directory structure (various ways of slicing a market sector
segmentation model) they will be presented with pages which either show
a default web page or else specific content. The layout and content is
user-configurable and is stored in the database and retrieved with the
home page object.

There's a directory browser control which manages the navigation and
maintains some session state (basically encapsulates an object
containing a hashtable of available dimension lists and a stack of
selected ones). It raises an event when the current directory path
changes, passing a specification object which is picked up by the page.
The page then uses that to obtain a MarketSectorHomePage.

The MarketSectorHomePage is exposed by the page via an interface, and is
displayed by a home page control. So we have:

public class ViewMSHP : System.Web.UI.Page,
IMarketSectorHomePageHost{...}

where IMarketSectorHomePageHost is defined as:

public interface IMarketSectorHomePageHost
{
MarketSectorHomePage MarketSectorHomePage
{
get;
set;
}
}

The base class of the home page control (BaseMarketSectorControl)
accesses the interface in the page like so:

IMarketSectorHomePageHost host = this.Page as IMarketSectorHomePageHost;

and exposes the MarketSectorHomePage to derived classes through a
protected property.

In CreateChildControls the home page control then examines the
MarketSectorHomePage object's PageContents object which defines the
names of the controls and their row and column positions. It creates a
table, inserting table cells and populating them with custom controls
created by reflection from the names defined in page contents. The
controls may or may not themselves be derived from
BaseMarketSectorControl, depending on whether they need to access and
render information from the MarketSectorHomePage.

This model works nicely when the MarketSectorHomePage is not changing
between postbacks, however when used in the above scenario where a
postback is induced by the directory browser it falls over. The control
tree created by the homepage control is not the same one as present on
the previous call, ASPNET can't find the controls where it thinks they
should be, and blows up.

It occurs to me that the same sort of thing would happen in many
scenarios with a classic model-view-controller architecture (and this
is, if you squint, MVC-like with looser than usual coupling).

After much messing about, I found a neat but unsatisfying workaround;
insert two instances of the home page control at the same location in
the page. Set the visible property of one to true, the other to false.
In OnPreRender, toggle the Visible property. Thus neither control is
visible both before and after a postback. If it isn't visible, it isn't
rendered, CreateChildControls doesn't run, everything works.

It works, but I wonder whether anyone has found a better way of dealing
with it?

--
Steve Walker
Nov 17 '05 #1
0 883

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

Similar topics

2
by: HI-Lab * the Social Technology | last post by:
Is there another function or a workaround to have same results of html_entity_decode in php 4.1.x? Thanks. -- ======================================= HI-LAB the Social Technology...
6
by: Chris | last post by:
hi, to convert excel files via csv to xml or whatever I frequently use the csv module which is really nice for quick scripts. problem are of course non ascii characters like german umlauts, EURO...
100
by: Peter | last post by:
Company thought DB2 will be better than Oracle. The bottom line is when you do select, the system crash. I think it may take 4-5 years for DB2 to reach Oracle standard. Peter
16
by: Bhushit Joshipura | last post by:
This post contains one question and one proposal. A. May I know why order of evaluation of arguments is not specified in C/C++? I asked a question in comp.lang.c++ for the following...
1
by: Ronaldo N | last post by:
I'm trying to do some javascript form validation and I've discovered a rather difficult situation to handle with IE. Let's say there's a form with three input fields named "name", "method", or...
7
by: Justin Shen | last post by:
the output of the following codes is "greater than zero", which is rather strange! the correct one should be "not greater than zero" int a = 0x79de61c0; //2044617152; a += 0x12345678; //a is...
9
by: Mickey Segal | last post by:
The long-simmering Eolas patent dispute: http://www.microsoft.com/presspass/press/2003/oct03/10-06EOLASPR.mspx has led to an optional Microsoft Update: http://support.microsoft.com/kb/912945/en-us...
1
by: slyi | last post by:
Hi All, Does anyone use vml to force the printing of background-colors in IE clients? Regards, slyi eg: <html xmlns:v="urn:schemas-microsoft-com:vml" >
0
by: William Johnston | last post by:
Hi, A support technician proposed a workaround to black images created for thumbnails. The code to create a thumbnail is below: //passes results to Response.OutputStream private void...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.