With 1 to n, I would not use panels (first suggestion). The controls or
pages with Server.Transfer both apply. The decision of which to do is
largely based on who maintains content items. If you have a graphic designer
maintaining the content, I would go with pages, as controls require the
person to either use notepad or have a copy of a .NET editor (Visual Studio
..NET, SharpDevelop, et al).
The basic tree goes like this, with pages:
----------------------------------------
Assuming URL format of
http://mysite.com/pageLoader.aspx?ID=1
pageLoader.aspx - page that gets ID
page1.aspx
page2.aspx
page3.aspx
page4.aspx
In pageLoader.aspx:
VB.NET
Dim id As String = Request("ID").ToString()
Server.Transfer("page" & id & ".aspx")
C#
string id = Request("ID").ToString();
Server.Transfer("page" + id + ".aspx");
Controls
---------
Controls gets a bit more complex (and more difficult to maintain for graphic
designers/HTML artists).
pageLoader.aspx - for consistency
page1.ascx
page2.ascx
page3.ascx
page4.ascx
In pageLoader.aspx you will drag a panel on the page in design view. I will
use Panel1, as that is the default, but you would probably want to be more
descriptive. In the CodeBehind (.vb or .cs file), you will use a statement
like this:
VB.NET
Dim id As Integer = Convert.ToInt32(Request("ID"))
Select Case id
Case 1
Panel1.Controls.Add(page1)
Case 2
Panel1.Controls.Add(page2)
Case 3
Panel1.Controls.Add(page3)
End Select
C#
int id = Convert.ToInt32(Request("ID"));
switch(id)
{
case 1:
Panel1.Controls.Add(page1);
break;
case 2:
Panel1.Controls.Add(page2);
break;
case 3:
Panel1.Controls.Add(page3);
break;
}
In this example, you can name the added controls anything you want, so
Panel1.Controls.Add(Administrators)
Panel1.Controls.Add(Users)
You would then make controls Administrators.ascx and Users.ascx.
NOTE: You can also apply this type of logic to example1 (with pages), if you
wish to have the pages by role (Administrators, Users, ReportUsers, et al)
instead of numbers (page1, page2, page3).
Back to pages
--------------
Assuming the following pages
pageLoader.aspx
Admin.aspx
User.aspx
ReportUser.aspx
VB.NET
Dim id As Integer = Convert.ToInt32(Request("ID"))
Select Case id
Case 1
Server.Transfer("Admin.aspx")
Case 2
Server.Transfer("User.aspx")
Case 3
Server.Transfer("ReportUser.aspx")
End Select
C#
int id = Convert.ToInt32(Request("ID"));
switch(id)
{
case 1:
Server.Transfer("Admin.aspx");
break;
case 2:
Server.Transfer("User.aspx");
break;
case 3:
Server.Transfer("ReportUser.aspx");
break;
}
Okay, you are probably at information overload right now. I would suggest
trying the page version first, as it is the easiest to design for. You can
either use the simplified version (page1.aspx, et al) or the role version
(Admin.aspx). I would suggest matching ID to page#.aspx, as it is easier.
You can move over to the role based version, if it makes more sense, after
you have things working.
For your own experience, experiment with the controls version at some time,
as you might find it better suited for your app(s) in the long run.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
**********************************************************************
Think Outside the Box!
**********************************************************************
Jane sharpe said:
Thanks Gregory,
I think I understand what you're saying (sorry, I'm still learning) - th
enumber of pages to join is variable from 1 to n, does this effect your
answer at all ?