Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

site design strategy (using user controls)

Status
Not open for further replies.

ikswoktur

Programmer
Oct 11, 2002
29
US
I am new to the .net framework and was wondering about site design planning, specifically the use of user controls. Is it better to:

1. have one page with a user control for the header, footer, menu and content, and simply change the user control for the content based on the users request to navigate to a new page. so, essentally one aspx page and many user controls.

or

2. have user controls for the components that are used many times (header, footer, menu) and have a new aspx for every page on the site that would include these user controls.

or

3. some other solution...

Thanks.
 
Having a user control for header, footer, etc. is a good idea either way, since they are common for the whole site. Having one page or multiple ones depends on how the "content" control has to change based on the user's request; if you'll have to recreate the whole control on each request so your code behind will grow huge, then it won't worth it - better have multiple pages.
 
If you DO end up going with the one page/ variable content control, I would recommend that you at least have the page content set according to a variable in the QueryString. It's nice for the user to be able to link to a given page without having to worry about re-navigation.
 
Thanks for the comments. i am going to go with the one page approach for the current project. i am also going to be using the QueryString approach. the way i am doing it is to clear out all controls and reload them all again when the user clicks on a link. i am using a QS variable to load the proper content user control (named the same). is this the best way? or is there a way to only clear the one control i want to change?
 
You'd probablly want to have some central panel control whose contents are determined by a processing page or something. I recommend you also look into caching the pages constant controls if you haven't already.
 
I am very curious about this. I have been using the one aspx approach. Here is a code snippet of the code behind.

PlaceHolder PlaceHolder1 = new PlaceHolder();
int i_pageID = Convert.ToInt32(Request.QueryString["pageID"]);
switch(i_pageID)
{
case 1:
{
Control body = Page.LoadControl("~/uc_adduser.ascx");
placeholder1.Controls.Add(body);
break;
}
case 2:
{
Control body = Page.LoadControl("~/uc_changepassword.ascx");
placeholder1.Controls.Add(body);
break;
}
case 3:
{
Control body = Page.LoadControl("~/uc_login.ascx");
placeholder1.Controls.Add(body);
break;
}
case 4:
{
Control body = Page.LoadControl("~/uc_usertable.ascx");
placeholder1.Controls.Add(body);
break;
}
default:
{
Control body = Page.LoadControl("~/uc_login.ascx");
placeholder1.Controls.Add(body);
break;
}
}

What do you mean ikswoktur by clearing out all the controls?
Without building a mirror site how could one prove that this is not using more resources than the same usercontrols in many aspx. I believe the one aspx is much easier to maintain. The bussiness layer and DAL are all in the individual usercontrols.
tyvm,
Marty
 
Hi all - anyone interested in this topic should check out the GotCommunityNet open source system available here:


They take the "one page"/"variable content" thing a step further by using an HttpModule to pick out the name of the file requested and query for content based on that, so all they have is ONE page, called CommunityDefault.aspx, but you can have urls like /home.aspx, /info.aspx, /contact.aspx, etc. NONE of which actually exist - through a Server.Transfer() call during the Application_BeginRequest event, all "pages" are actually CommunityDefault.aspx. Pretty slick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top