Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Multiple Placeholders or One to load controls

Reply
Thread Tools

Multiple Placeholders or One to load controls

 
 
tshad
Guest
Posts: n/a
 
      07-30-2007
I am using asp.net 1.1 and am creating my pages with different looks and
using controls for each part of the page (top, bottom, navigation etc)

The way I have it set up is the following where I have 4 different controls
(one for each page part). I am looking at a couple other ways of doing this
as well and was wondering if there is a drawback to doing the others.

*****************************************
<%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim pageTop as String
Dim navigateTop as String
Dim pageBottom as String
Dim pageTopControl as Control
Dim navigateTopControl as Control
Dim pageBottomControl as Control
Dim LogonControl as Control
Dim skinArray as ArrayList = Application("SkinArray")

pageTop = "PageTop.ascx"
navigateTop = "NavigateTop.ascx"
pageBottom = "PageBottom.ascx"

pageTopControl = LoadControl(pageTop)
PageTopPanel.Controls.Add(pageTopControl)
navigateTopControl = LoadControl(navigateTop)
NavigateTopPanel.Controls.Add(navigateTopControl)
LogonControl = LoadControl("DisplayCompanyJobs.ascx")
LogonPanel.Controls.Add(LogonControl)
pageBottomControl = LoadControl(pageBottom)
PageBottomPanel.Controls.Add(pageBottomControl)
end Sub
</script>

<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" runat="server">
<form id="addForm" runat="server">

<asplaceHolder ID="PageTopPanel" runat="server"/>
<asplaceHolder ID="NavigateTopPanel" runat="server"/>
<asplaceHolder ID="LogonPanel" runat="server"/>
<asplaceHolder ID="PageBottomPanel" runat="server"/>

</form>
</body>
</html>
******************************************

Another way is to have only one Placeholder and load them one by one. Not
sure if this would have any performance impact or not. I am still loading 4
pages. Would the controls always display in the order they are loaded into
the PlaceHolder?

*****************************************
<%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim pageTop as String
Dim navigateTop as String
Dim pageBottom as String
Dim pageTopControl as Control
Dim navigateTopControl as Control
Dim pageBottomControl as Control
Dim LogonControl as Control
Dim skinArray as ArrayList = Application("SkinArray")

pageTop = "PageTop.ascx"
navigateTop = "NavigateTop.ascx"
pageBottom = "PageBottom.ascx"

pageTopControl = LoadControl(pageTop)
thePlaceHolder.Controls.Add(pageTopControl)
navigateTopControl = LoadControl(navigateTop)
thePlaceHolder.Controls.Add(navigateTopControl)
LogonControl = LoadControl("DisplayCompanyJobs.ascx")
thePlaceHolder.Controls.Add(LogonControl)
pageBottomControl = LoadControl(pageBottom)
thePlaceHolder.Controls.Add(pageBottomControl)
end Sub
</script>

<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" runat="server">
<form id="addForm" runat="server">

<asplaceHolder ID="thePlaceHolder" runat="server"/>

</form>
</body>
</html>
******************************************

The other way is to just build the whole page and have that page as a
control and have it just load the content section as a control
(DisplayCompanyJobs.ascx in my example).

Not sure if I would be saving a lot here as I am still loading a couple of
pages.

Thanks,

Tom



 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      07-31-2007
It's kind of hard to advise you without knowing a bit more about your
requirements and design. For example, from your code, I don't see why you're
using all that logic to load the User Controls into the page, when you could
just reference them with tags in the page markup.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"tshad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am using asp.net 1.1 and am creating my pages with different looks and
>using controls for each part of the page (top, bottom, navigation etc)
>
> The way I have it set up is the following where I have 4 different
> controls (one for each page part). I am looking at a couple other ways of
> doing this as well and was wondering if there is a drawback to doing the
> others.
>
> *****************************************
> <%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
> ResponseEncoding="iso-8859-1" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <script runat="server">
> Sub Page_Load(sender as Object, e as EventArgs)
> Dim pageTop as String
> Dim navigateTop as String
> Dim pageBottom as String
> Dim pageTopControl as Control
> Dim navigateTopControl as Control
> Dim pageBottomControl as Control
> Dim LogonControl as Control
> Dim skinArray as ArrayList = Application("SkinArray")
>
> pageTop = "PageTop.ascx"
> navigateTop = "NavigateTop.ascx"
> pageBottom = "PageBottom.ascx"
>
> pageTopControl = LoadControl(pageTop)
> PageTopPanel.Controls.Add(pageTopControl)
> navigateTopControl = LoadControl(navigateTop)
> NavigateTopPanel.Controls.Add(navigateTopControl)
> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
> LogonPanel.Controls.Add(LogonControl)
> pageBottomControl = LoadControl(pageBottom)
> PageBottomPanel.Controls.Add(pageBottomControl)
> end Sub
> </script>
>
> <html>
> <head>
> <title>:: Staffing Workshop ::</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
> marginheight="0" runat="server">
> <form id="addForm" runat="server">
>
> <asplaceHolder ID="PageTopPanel" runat="server"/>
> <asplaceHolder ID="NavigateTopPanel" runat="server"/>
> <asplaceHolder ID="LogonPanel" runat="server"/>
> <asplaceHolder ID="PageBottomPanel" runat="server"/>
>
> </form>
> </body>
> </html>
> ******************************************
>
> Another way is to have only one Placeholder and load them one by one. Not
> sure if this would have any performance impact or not. I am still loading
> 4 pages. Would the controls always display in the order they are loaded
> into the PlaceHolder?
>
> *****************************************
> <%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
> ResponseEncoding="iso-8859-1" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <script runat="server">
> Sub Page_Load(sender as Object, e as EventArgs)
> Dim pageTop as String
> Dim navigateTop as String
> Dim pageBottom as String
> Dim pageTopControl as Control
> Dim navigateTopControl as Control
> Dim pageBottomControl as Control
> Dim LogonControl as Control
> Dim skinArray as ArrayList = Application("SkinArray")
>
> pageTop = "PageTop.ascx"
> navigateTop = "NavigateTop.ascx"
> pageBottom = "PageBottom.ascx"
>
> pageTopControl = LoadControl(pageTop)
> thePlaceHolder.Controls.Add(pageTopControl)
> navigateTopControl = LoadControl(navigateTop)
> thePlaceHolder.Controls.Add(navigateTopControl)
> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
> thePlaceHolder.Controls.Add(LogonControl)
> pageBottomControl = LoadControl(pageBottom)
> thePlaceHolder.Controls.Add(pageBottomControl)
> end Sub
> </script>
>
> <html>
> <head>
> <title>:: Staffing Workshop ::</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
> marginheight="0" runat="server">
> <form id="addForm" runat="server">
>
> <asplaceHolder ID="thePlaceHolder" runat="server"/>
>
> </form>
> </body>
> </html>
> ******************************************
>
> The other way is to just build the whole page and have that page as a
> control and have it just load the content section as a control
> (DisplayCompanyJobs.ascx in my example).
>
> Not sure if I would be saving a lot here as I am still loading a couple of
> pages.
>
> Thanks,
>
> Tom
>
>
>



 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      07-31-2007
"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It's kind of hard to advise you without knowing a bit more about your
> requirements and design. For example, from your code, I don't see why
> you're using all that logic to load the User Controls into the page, when
> you could just reference them with tags in the page markup.


Each one of the Controls is a different part of the page, mainly html code.
The Content control has all the asp.net code with textboxes, labels,
datagrids etc.

Each control is different for each client and the controls come from
different folders depending on the client. This is why the controls are not
static. The PageTop control could be "skins\ft\displaypage.ascx" for one
client and "skins\jl\displaypage.ascx" for another. I am not showing the
whole code to make it simpler for my example. I would normally build the
Folders (skins\ft for example) based on a session variable.

Originally, I had multiple controls because I was thinking that the Forms
tags need to be only around the Content Control (LogonControl ), in my
example.

Now I find that I can put the Forms tag around all the controls without any
problems. So that being the case, I could just set up the 2nd example
(thePlaceHolder), which just houses all the controls. Not sure if I am
gaining anything here.

The last case was just to have the whole page built for each client and on
each page are the controls I need (content and navigation mainly) and just
access the controls that way.

Thanks,

Tom
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
>
> Printing Components, Email Components,
> FTP Client Classes, Enhanced Data Controls, much more.
> DSI PrintManager, Miradyne Component Libraries:
> http://www.miradyne.net
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I am using asp.net 1.1 and am creating my pages with different looks and
>>using controls for each part of the page (top, bottom, navigation etc)
>>
>> The way I have it set up is the following where I have 4 different
>> controls (one for each page part). I am looking at a couple other ways
>> of doing this as well and was wondering if there is a drawback to doing
>> the others.
>>
>> *****************************************
>> <%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
>> ResponseEncoding="iso-8859-1" %>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>> <script runat="server">
>> Sub Page_Load(sender as Object, e as EventArgs)
>> Dim pageTop as String
>> Dim navigateTop as String
>> Dim pageBottom as String
>> Dim pageTopControl as Control
>> Dim navigateTopControl as Control
>> Dim pageBottomControl as Control
>> Dim LogonControl as Control
>> Dim skinArray as ArrayList = Application("SkinArray")
>>
>> pageTop = "PageTop.ascx"
>> navigateTop = "NavigateTop.ascx"
>> pageBottom = "PageBottom.ascx"
>>
>> pageTopControl = LoadControl(pageTop)
>> PageTopPanel.Controls.Add(pageTopControl)
>> navigateTopControl = LoadControl(navigateTop)
>> NavigateTopPanel.Controls.Add(navigateTopControl)
>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>> LogonPanel.Controls.Add(LogonControl)
>> pageBottomControl = LoadControl(pageBottom)
>> PageBottomPanel.Controls.Add(pageBottomControl)
>> end Sub
>> </script>
>>
>> <html>
>> <head>
>> <title>:: Staffing Workshop ::</title>
>> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>> marginheight="0" runat="server">
>> <form id="addForm" runat="server">
>>
>> <asplaceHolder ID="PageTopPanel" runat="server"/>
>> <asplaceHolder ID="NavigateTopPanel" runat="server"/>
>> <asplaceHolder ID="LogonPanel" runat="server"/>
>> <asplaceHolder ID="PageBottomPanel" runat="server"/>
>>
>> </form>
>> </body>
>> </html>
>> ******************************************
>>
>> Another way is to have only one Placeholder and load them one by one.
>> Not sure if this would have any performance impact or not. I am still
>> loading 4 pages. Would the controls always display in the order they are
>> loaded into the PlaceHolder?
>>
>> *****************************************
>> <%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
>> ResponseEncoding="iso-8859-1" %>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>> <script runat="server">
>> Sub Page_Load(sender as Object, e as EventArgs)
>> Dim pageTop as String
>> Dim navigateTop as String
>> Dim pageBottom as String
>> Dim pageTopControl as Control
>> Dim navigateTopControl as Control
>> Dim pageBottomControl as Control
>> Dim LogonControl as Control
>> Dim skinArray as ArrayList = Application("SkinArray")
>>
>> pageTop = "PageTop.ascx"
>> navigateTop = "NavigateTop.ascx"
>> pageBottom = "PageBottom.ascx"
>>
>> pageTopControl = LoadControl(pageTop)
>> thePlaceHolder.Controls.Add(pageTopControl)
>> navigateTopControl = LoadControl(navigateTop)
>> thePlaceHolder.Controls.Add(navigateTopControl)
>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>> thePlaceHolder.Controls.Add(LogonControl)
>> pageBottomControl = LoadControl(pageBottom)
>> thePlaceHolder.Controls.Add(pageBottomControl)
>> end Sub
>> </script>
>>
>> <html>
>> <head>
>> <title>:: Staffing Workshop ::</title>
>> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>> marginheight="0" runat="server">
>> <form id="addForm" runat="server">
>>
>> <asplaceHolder ID="thePlaceHolder" runat="server"/>
>>
>> </form>
>> </body>
>> </html>
>> ******************************************
>>
>> The other way is to just build the whole page and have that page as a
>> control and have it just load the content section as a control
>> (DisplayCompanyJobs.ascx in my example).
>>
>> Not sure if I would be saving a lot here as I am still loading a couple
>> of pages.
>>
>> Thanks,
>>
>> Tom
>>
>>
>>

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      07-31-2007
Hi Tom,

I'm still thinking that there is something awry about your architecture.
Skins are generally much simpler to use than you're describing. In fact,
depending upon your requirements again, if all you're doing is changing the
look of the page, this can be done for the most part using a CSS style
sheet, and dynamic styles. But skins are okay, and come in handy from time
to time. Still, as I said, the model for using them is simpler than what
you're describing.

Controls are dynamic by nature rather than static, so it still seems like
you've got an extra layer of indirection with the Placeholders. I have found
that many times in my experience I've stepped back after a number of
changes, taken a fresh look at the architecture from my new viewpoint
(having done some of the actual work), and decided to take a fresh approach
to the issue. One common mistake I've seen, and I can't tell if you're
actually making this one, is that developers will often take too much
advantage of the dynamic nature of ASP.Net and make one page or one Control
do too many things. A simpler, more modular approach is generally easier to
maintain in the long run. But as I said, that's only a general observation,
not necessarily applicable to your current situation.

At any rate, in answer to your question regarding the order of loading of
the PlaceHolders, yes, they will always appear in the order you place them
in the Page.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"tshad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Kevin Spencer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> It's kind of hard to advise you without knowing a bit more about your
>> requirements and design. For example, from your code, I don't see why
>> you're using all that logic to load the User Controls into the page, when
>> you could just reference them with tags in the page markup.

>
> Each one of the Controls is a different part of the page, mainly html
> code. The Content control has all the asp.net code with textboxes, labels,
> datagrids etc.
>
> Each control is different for each client and the controls come from
> different folders depending on the client. This is why the controls are
> not static. The PageTop control could be "skins\ft\displaypage.ascx" for
> one client and "skins\jl\displaypage.ascx" for another. I am not showing
> the whole code to make it simpler for my example. I would normally build
> the Folders (skins\ft for example) based on a session variable.
>
> Originally, I had multiple controls because I was thinking that the Forms
> tags need to be only around the Content Control (LogonControl ), in my
> example.
>
> Now I find that I can put the Forms tag around all the controls without
> any problems. So that being the case, I could just set up the 2nd example
> (thePlaceHolder), which just houses all the controls. Not sure if I am
> gaining anything here.
>
> The last case was just to have the whole page built for each client and on
> each page are the controls I need (content and navigation mainly) and just
> access the controls that way.
>
> Thanks,
>
> Tom
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>>
>> Printing Components, Email Components,
>> FTP Client Classes, Enhanced Data Controls, much more.
>> DSI PrintManager, Miradyne Component Libraries:
>> http://www.miradyne.net
>>
>> "tshad" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I am using asp.net 1.1 and am creating my pages with different looks and
>>>using controls for each part of the page (top, bottom, navigation etc)
>>>
>>> The way I have it set up is the following where I have 4 different
>>> controls (one for each page part). I am looking at a couple other ways
>>> of doing this as well and was wondering if there is a drawback to doing
>>> the others.
>>>
>>> *****************************************
>>> <%@ Page Language="VB" trace="false" debug="true"
>>> ContentType="text/html"
>>> ResponseEncoding="iso-8859-1" %>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>> "http://www.w3.org/TR/html4/loose.dtd">
>>> <script runat="server">
>>> Sub Page_Load(sender as Object, e as EventArgs)
>>> Dim pageTop as String
>>> Dim navigateTop as String
>>> Dim pageBottom as String
>>> Dim pageTopControl as Control
>>> Dim navigateTopControl as Control
>>> Dim pageBottomControl as Control
>>> Dim LogonControl as Control
>>> Dim skinArray as ArrayList = Application("SkinArray")
>>>
>>> pageTop = "PageTop.ascx"
>>> navigateTop = "NavigateTop.ascx"
>>> pageBottom = "PageBottom.ascx"
>>>
>>> pageTopControl = LoadControl(pageTop)
>>> PageTopPanel.Controls.Add(pageTopControl)
>>> navigateTopControl = LoadControl(navigateTop)
>>> NavigateTopPanel.Controls.Add(navigateTopControl)
>>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>>> LogonPanel.Controls.Add(LogonControl)
>>> pageBottomControl = LoadControl(pageBottom)
>>> PageBottomPanel.Controls.Add(pageBottomControl)
>>> end Sub
>>> </script>
>>>
>>> <html>
>>> <head>
>>> <title>:: Staffing Workshop ::</title>
>>> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>>> marginheight="0" runat="server">
>>> <form id="addForm" runat="server">
>>>
>>> <asplaceHolder ID="PageTopPanel" runat="server"/>
>>> <asplaceHolder ID="NavigateTopPanel" runat="server"/>
>>> <asplaceHolder ID="LogonPanel" runat="server"/>
>>> <asplaceHolder ID="PageBottomPanel" runat="server"/>
>>>
>>> </form>
>>> </body>
>>> </html>
>>> ******************************************
>>>
>>> Another way is to have only one Placeholder and load them one by one.
>>> Not sure if this would have any performance impact or not. I am still
>>> loading 4 pages. Would the controls always display in the order they
>>> are loaded into the PlaceHolder?
>>>
>>> *****************************************
>>> <%@ Page Language="VB" trace="false" debug="true"
>>> ContentType="text/html"
>>> ResponseEncoding="iso-8859-1" %>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>> "http://www.w3.org/TR/html4/loose.dtd">
>>> <script runat="server">
>>> Sub Page_Load(sender as Object, e as EventArgs)
>>> Dim pageTop as String
>>> Dim navigateTop as String
>>> Dim pageBottom as String
>>> Dim pageTopControl as Control
>>> Dim navigateTopControl as Control
>>> Dim pageBottomControl as Control
>>> Dim LogonControl as Control
>>> Dim skinArray as ArrayList = Application("SkinArray")
>>>
>>> pageTop = "PageTop.ascx"
>>> navigateTop = "NavigateTop.ascx"
>>> pageBottom = "PageBottom.ascx"
>>>
>>> pageTopControl = LoadControl(pageTop)
>>> thePlaceHolder.Controls.Add(pageTopControl)
>>> navigateTopControl = LoadControl(navigateTop)
>>> thePlaceHolder.Controls.Add(navigateTopControl)
>>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>>> thePlaceHolder.Controls.Add(LogonControl)
>>> pageBottomControl = LoadControl(pageBottom)
>>> thePlaceHolder.Controls.Add(pageBottomControl)
>>> end Sub
>>> </script>
>>>
>>> <html>
>>> <head>
>>> <title>:: Staffing Workshop ::</title>
>>> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>>> marginheight="0" runat="server">
>>> <form id="addForm" runat="server">
>>>
>>> <asplaceHolder ID="thePlaceHolder" runat="server"/>
>>>
>>> </form>
>>> </body>
>>> </html>
>>> ******************************************
>>>
>>> The other way is to just build the whole page and have that page as a
>>> control and have it just load the content section as a control
>>> (DisplayCompanyJobs.ascx in my example).
>>>
>>> Not sure if I would be saving a lot here as I am still loading a couple
>>> of pages.
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      07-31-2007
You're right about the architecture.

I wrote the original design about a year ago that I never got to. I started
working with the page and after finding out that I could just move the
<form> tags to just after the <body> tag without any problems, that solved a
lot of problems and questions. I was trying to determine the goods and bads
of various approaches.

What we are doing is allowing our clients to have their own custom pages
with an area for our software which includes names, addresses, datagrids of
date etc. We need our own menus but will need to adjust the look depending
on the look of the page - controlled by CSS. In most cases, the page will
have a top, left and bottom page with our content going in the middle-right
section of the page. I already have it pretty much working (with a couple
of issues I found during testing the first few pages and posted last night).

The page looks like:
************************************************** **************
<%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim thePage as String
Dim pageControl as Control
Dim navigation as String
Dim contentControl as Control
Dim a as htmlControl
Dim skinArray as ArrayList = Application("SkinArray")
for i as integer = 0 to skinArray.Count - 1 step 3
if skinArray(i) = request("MID") then
session("CompanyInitials") = skinArray(i+1)
end if
Next
if not session("CompanyInitials") is Nothing then
thePage = "/skins/" & session("CompanyInitials") & "/" & "MainPage" &
".ascx"
navigation = "NavigateTop" & ".ascx"
end if
pageControl = LoadControl(thePage)
thePlaceHolder.Controls.Add(pageControl)
contentControl =
CType(thePlaceHolder.FindControl("_ctl0:Navigation "),Control)
contentControl.Controls.Add(LoadControl(navigation ))
contentControl = CType(Page.FindControl("_ctl0:Content"),Control)
contentControl.Controls.Add(LoadControl("/applicant/DisplayCompanyJobs.ascx"))

end Sub

</script>
<html>
<head>
<title>:: SW::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" runat="server">
<form id="addForm" runat="server">
<asplaceHolder ID="thePlaceHolder" runat="server"/>
</form>
</body>
</html>
************************************************** **************

As you can see, I have replaced the 4 controls with 1. This is the whole
page designed specifically for the client. I put 2 controls on this page
somewhere. Would be a different place for each (1 for content and 1 for
navigation menus/links). I then then load the 2 controls into these
controls.

The other change I think I am going to make is to take all the asp.net code
and move it to a control and load that also. That way if I make any changes
to the code, I only have to make it in one place. I will literally have
100+ identical pages with only the content control (which would be different
for each page) being different:

contentControl = CType(Page.FindControl("_ctl0:Content"),Control)
contentControl.Controls.Add(LoadControl("/applicant/DisplayCompanyJobs.ascx"))

If there was a way to do this with one page that would be nice, but I need a
page for each page being called.

This seems like it will work pretty well once I solve the problem with the
asp:HyperLink which doesn't seem to be working correctly, as I mentioned in
another post. Everything else seems to be working.

I am sure there are other (and maybe better ways) but this seems pretty
clean and maintainable.

Thanks,

Tom

"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Tom,
>
> I'm still thinking that there is something awry about your architecture.
> Skins are generally much simpler to use than you're describing. In fact,
> depending upon your requirements again, if all you're doing is changing
> the look of the page, this can be done for the most part using a CSS style
> sheet, and dynamic styles. But skins are okay, and come in handy from time
> to time. Still, as I said, the model for using them is simpler than what
> you're describing.
>
> Controls are dynamic by nature rather than static, so it still seems like
> you've got an extra layer of indirection with the Placeholders. I have
> found that many times in my experience I've stepped back after a number of
> changes, taken a fresh look at the architecture from my new viewpoint
> (having done some of the actual work), and decided to take a fresh
> approach to the issue. One common mistake I've seen, and I can't tell if
> you're actually making this one, is that developers will often take too
> much advantage of the dynamic nature of ASP.Net and make one page or one
> Control do too many things. A simpler, more modular approach is generally
> easier to maintain in the long run. But as I said, that's only a general
> observation, not necessarily applicable to your current situation.
>
> At any rate, in answer to your question regarding the order of loading of
> the PlaceHolders, yes, they will always appear in the order you place them
> in the Page.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
>
> Printing Components, Email Components,
> FTP Client Classes, Enhanced Data Controls, much more.
> DSI PrintManager, Miradyne Component Libraries:
> http://www.miradyne.net
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "Kevin Spencer" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> It's kind of hard to advise you without knowing a bit more about your
>>> requirements and design. For example, from your code, I don't see why
>>> you're using all that logic to load the User Controls into the page,
>>> when you could just reference them with tags in the page markup.

>>
>> Each one of the Controls is a different part of the page, mainly html
>> code. The Content control has all the asp.net code with textboxes,
>> labels, datagrids etc.
>>
>> Each control is different for each client and the controls come from
>> different folders depending on the client. This is why the controls are
>> not static. The PageTop control could be "skins\ft\displaypage.ascx" for
>> one client and "skins\jl\displaypage.ascx" for another. I am not showing
>> the whole code to make it simpler for my example. I would normally build
>> the Folders (skins\ft for example) based on a session variable.
>>
>> Originally, I had multiple controls because I was thinking that the Forms
>> tags need to be only around the Content Control (LogonControl ), in my
>> example.
>>
>> Now I find that I can put the Forms tag around all the controls without
>> any problems. So that being the case, I could just set up the 2nd
>> example (thePlaceHolder), which just houses all the controls. Not sure
>> if I am gaining anything here.
>>
>> The last case was just to have the whole page built for each client and
>> on each page are the controls I need (content and navigation mainly) and
>> just access the controls that way.
>>
>> Thanks,
>>
>> Tom
>>>
>>> --
>>> HTH,
>>>
>>> Kevin Spencer
>>> Microsoft MVP
>>>
>>> Printing Components, Email Components,
>>> FTP Client Classes, Enhanced Data Controls, much more.
>>> DSI PrintManager, Miradyne Component Libraries:
>>> http://www.miradyne.net
>>>
>>> "tshad" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I am using asp.net 1.1 and am creating my pages with different looks and
>>>>using controls for each part of the page (top, bottom, navigation etc)
>>>>
>>>> The way I have it set up is the following where I have 4 different
>>>> controls (one for each page part). I am looking at a couple other ways
>>>> of doing this as well and was wondering if there is a drawback to doing
>>>> the others.
>>>>
>>>> *****************************************
>>>> <%@ Page Language="VB" trace="false" debug="true"
>>>> ContentType="text/html"
>>>> ResponseEncoding="iso-8859-1" %>
>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>> <script runat="server">
>>>> Sub Page_Load(sender as Object, e as EventArgs)
>>>> Dim pageTop as String
>>>> Dim navigateTop as String
>>>> Dim pageBottom as String
>>>> Dim pageTopControl as Control
>>>> Dim navigateTopControl as Control
>>>> Dim pageBottomControl as Control
>>>> Dim LogonControl as Control
>>>> Dim skinArray as ArrayList = Application("SkinArray")
>>>>
>>>> pageTop = "PageTop.ascx"
>>>> navigateTop = "NavigateTop.ascx"
>>>> pageBottom = "PageBottom.ascx"
>>>>
>>>> pageTopControl = LoadControl(pageTop)
>>>> PageTopPanel.Controls.Add(pageTopControl)
>>>> navigateTopControl = LoadControl(navigateTop)
>>>> NavigateTopPanel.Controls.Add(navigateTopControl)
>>>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>>>> LogonPanel.Controls.Add(LogonControl)
>>>> pageBottomControl = LoadControl(pageBottom)
>>>> PageBottomPanel.Controls.Add(pageBottomControl)
>>>> end Sub
>>>> </script>
>>>>
>>>> <html>
>>>> <head>
>>>> <title>:: Staffing Workshop ::</title>
>>>> <meta http-equiv="Content-Type" content="text/html;
>>>> charset=iso-8859-1">
>>>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>>>> marginheight="0" runat="server">
>>>> <form id="addForm" runat="server">
>>>>
>>>> <asplaceHolder ID="PageTopPanel" runat="server"/>
>>>> <asplaceHolder ID="NavigateTopPanel" runat="server"/>
>>>> <asplaceHolder ID="LogonPanel" runat="server"/>
>>>> <asplaceHolder ID="PageBottomPanel" runat="server"/>
>>>>
>>>> </form>
>>>> </body>
>>>> </html>
>>>> ******************************************
>>>>
>>>> Another way is to have only one Placeholder and load them one by one.
>>>> Not sure if this would have any performance impact or not. I am still
>>>> loading 4 pages. Would the controls always display in the order they
>>>> are loaded into the PlaceHolder?
>>>>
>>>> *****************************************
>>>> <%@ Page Language="VB" trace="false" debug="true"
>>>> ContentType="text/html"
>>>> ResponseEncoding="iso-8859-1" %>
>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>> <script runat="server">
>>>> Sub Page_Load(sender as Object, e as EventArgs)
>>>> Dim pageTop as String
>>>> Dim navigateTop as String
>>>> Dim pageBottom as String
>>>> Dim pageTopControl as Control
>>>> Dim navigateTopControl as Control
>>>> Dim pageBottomControl as Control
>>>> Dim LogonControl as Control
>>>> Dim skinArray as ArrayList = Application("SkinArray")
>>>>
>>>> pageTop = "PageTop.ascx"
>>>> navigateTop = "NavigateTop.ascx"
>>>> pageBottom = "PageBottom.ascx"
>>>>
>>>> pageTopControl = LoadControl(pageTop)
>>>> thePlaceHolder.Controls.Add(pageTopControl)
>>>> navigateTopControl = LoadControl(navigateTop)
>>>> thePlaceHolder.Controls.Add(navigateTopControl)
>>>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>>>> thePlaceHolder.Controls.Add(LogonControl)
>>>> pageBottomControl = LoadControl(pageBottom)
>>>> thePlaceHolder.Controls.Add(pageBottomControl)
>>>> end Sub
>>>> </script>
>>>>
>>>> <html>
>>>> <head>
>>>> <title>:: Staffing Workshop ::</title>
>>>> <meta http-equiv="Content-Type" content="text/html;
>>>> charset=iso-8859-1">
>>>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>>>> marginheight="0" runat="server">
>>>> <form id="addForm" runat="server">
>>>>
>>>> <asplaceHolder ID="thePlaceHolder" runat="server"/>
>>>>
>>>> </form>
>>>> </body>
>>>> </html>
>>>> ******************************************
>>>>
>>>> The other way is to just build the whole page and have that page as a
>>>> control and have it just load the content section as a control
>>>> (DisplayCompanyJobs.ascx in my example).
>>>>
>>>> Not sure if I would be saving a lot here as I am still loading a couple
>>>> of pages.
>>>>
>>>> Thanks,
>>>>
>>>> Tom
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      08-01-2007
Hi Tom,

I can certainly see how you've arrived at the point you're at now. It is
often necessary to create something before one is able to create the best
possible thing, usually due to time constraints or conditions.

I have done a similar type of project myself, and it does include
PlaceHolders in various places in case of a need for special customization
by a particular client, although it is a more generic type of solution,
which doesn't include any content other than the client's content.

In my own experience, I used a combination of several different design ideas
and technologies. I used a basic HTML layout similar to that of
CSSZenGarden.com, which is highly flexible using an external style sheet,
but describes a layout "framework," if you will. I substituted ASP.Net
Panels for most of the divs, allowing me to dynamically change the content,
and a MasterPage for the overall layout. The MasterPage exposes the various
Controls it contains as properties which can be accessed by any page being
hosted in the MasterPage. The actual content of the pages comes from a
database, which includes Membership and Role Provider data in addition to
content data. Individual Panels can have different CSS classes assigned to
them if necessary, and the Style Sheet can be replaced completely for
different clients, so that the entire layout is more or less dynamic.

Various parts of the MasterPage can be hidden or displayed on a Page-by-Page
basis, and as I mentioned, many of the Panels in the MasterPage include
PlaceHolders for special cases.

Even now I can think of ways I might be able to improve the design, but I
too have to work within constraints. For example, I could store the actual
external Style Sheet in the database, and retrieve it with a special HTTP
Handler. Perhaps I'll be able to implement some of these in the future. I
don't know which of these options you may have already thought of, but those
are a few ideas you may want to think about for the future.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"tshad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You're right about the architecture.
>
> I wrote the original design about a year ago that I never got to. I
> started working with the page and after finding out that I could just move
> the <form> tags to just after the <body> tag without any problems, that
> solved a lot of problems and questions. I was trying to determine the
> goods and bads of various approaches.
>
> What we are doing is allowing our clients to have their own custom pages
> with an area for our software which includes names, addresses, datagrids
> of date etc. We need our own menus but will need to adjust the look
> depending on the look of the page - controlled by CSS. In most cases, the
> page will have a top, left and bottom page with our content going in the
> middle-right section of the page. I already have it pretty much working
> (with a couple of issues I found during testing the first few pages and
> posted last night).
>
> The page looks like:
> ************************************************** **************
> <%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
> ResponseEncoding="iso-8859-1" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <script runat="server">
> Sub Page_Load(sender as Object, e as EventArgs)
> Dim thePage as String
> Dim pageControl as Control
> Dim navigation as String
> Dim contentControl as Control
> Dim a as htmlControl
> Dim skinArray as ArrayList = Application("SkinArray")
> for i as integer = 0 to skinArray.Count - 1 step 3
> if skinArray(i) = request("MID") then
> session("CompanyInitials") = skinArray(i+1)
> end if
> Next
> if not session("CompanyInitials") is Nothing then
> thePage = "/skins/" & session("CompanyInitials") & "/" & "MainPage" &
> ".ascx"
> navigation = "NavigateTop" & ".ascx"
> end if
> pageControl = LoadControl(thePage)
> thePlaceHolder.Controls.Add(pageControl)
> contentControl =
> CType(thePlaceHolder.FindControl("_ctl0:Navigation "),Control)
> contentControl.Controls.Add(LoadControl(navigation ))
> contentControl = CType(Page.FindControl("_ctl0:Content"),Control)
>
> contentControl.Controls.Add(LoadControl("/applicant/DisplayCompanyJobs.ascx"))
>
> end Sub
>
> </script>
> <html>
> <head>
> <title>:: SW::</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
> marginheight="0" runat="server">
> <form id="addForm" runat="server">
> <asplaceHolder ID="thePlaceHolder" runat="server"/>
> </form>
> </body>
> </html>
> ************************************************** **************
>
> As you can see, I have replaced the 4 controls with 1. This is the whole
> page designed specifically for the client. I put 2 controls on this page
> somewhere. Would be a different place for each (1 for content and 1 for
> navigation menus/links). I then then load the 2 controls into these
> controls.
>
> The other change I think I am going to make is to take all the asp.net
> code and move it to a control and load that also. That way if I make any
> changes to the code, I only have to make it in one place. I will
> literally have 100+ identical pages with only the content control (which
> would be different for each page) being different:
>
> contentControl = CType(Page.FindControl("_ctl0:Content"),Control)
>
> contentControl.Controls.Add(LoadControl("/applicant/DisplayCompanyJobs.ascx"))
>
> If there was a way to do this with one page that would be nice, but I need
> a page for each page being called.
>
> This seems like it will work pretty well once I solve the problem with the
> asp:HyperLink which doesn't seem to be working correctly, as I mentioned
> in another post. Everything else seems to be working.
>
> I am sure there are other (and maybe better ways) but this seems pretty
> clean and maintainable.
>
> Thanks,
>
> Tom
>
> "Kevin Spencer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi Tom,
>>
>> I'm still thinking that there is something awry about your architecture.
>> Skins are generally much simpler to use than you're describing. In fact,
>> depending upon your requirements again, if all you're doing is changing
>> the look of the page, this can be done for the most part using a CSS
>> style sheet, and dynamic styles. But skins are okay, and come in handy
>> from time to time. Still, as I said, the model for using them is simpler
>> than what you're describing.
>>
>> Controls are dynamic by nature rather than static, so it still seems like
>> you've got an extra layer of indirection with the Placeholders. I have
>> found that many times in my experience I've stepped back after a number
>> of changes, taken a fresh look at the architecture from my new viewpoint
>> (having done some of the actual work), and decided to take a fresh
>> approach to the issue. One common mistake I've seen, and I can't tell if
>> you're actually making this one, is that developers will often take too
>> much advantage of the dynamic nature of ASP.Net and make one page or one
>> Control do too many things. A simpler, more modular approach is generally
>> easier to maintain in the long run. But as I said, that's only a general
>> observation, not necessarily applicable to your current situation.
>>
>> At any rate, in answer to your question regarding the order of loading of
>> the PlaceHolders, yes, they will always appear in the order you place
>> them in the Page.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>>
>> Printing Components, Email Components,
>> FTP Client Classes, Enhanced Data Controls, much more.
>> DSI PrintManager, Miradyne Component Libraries:
>> http://www.miradyne.net
>>
>> "tshad" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> "Kevin Spencer" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> It's kind of hard to advise you without knowing a bit more about your
>>>> requirements and design. For example, from your code, I don't see why
>>>> you're using all that logic to load the User Controls into the page,
>>>> when you could just reference them with tags in the page markup.
>>>
>>> Each one of the Controls is a different part of the page, mainly html
>>> code. The Content control has all the asp.net code with textboxes,
>>> labels, datagrids etc.
>>>
>>> Each control is different for each client and the controls come from
>>> different folders depending on the client. This is why the controls are
>>> not static. The PageTop control could be "skins\ft\displaypage.ascx"
>>> for one client and "skins\jl\displaypage.ascx" for another. I am not
>>> showing the whole code to make it simpler for my example. I would
>>> normally build the Folders (skins\ft for example) based on a session
>>> variable.
>>>
>>> Originally, I had multiple controls because I was thinking that the
>>> Forms tags need to be only around the Content Control (LogonControl ),
>>> in my example.
>>>
>>> Now I find that I can put the Forms tag around all the controls without
>>> any problems. So that being the case, I could just set up the 2nd
>>> example (thePlaceHolder), which just houses all the controls. Not sure
>>> if I am gaining anything here.
>>>
>>> The last case was just to have the whole page built for each client and
>>> on each page are the controls I need (content and navigation mainly) and
>>> just access the controls that way.
>>>
>>> Thanks,
>>>
>>> Tom
>>>>
>>>> --
>>>> HTH,
>>>>
>>>> Kevin Spencer
>>>> Microsoft MVP
>>>>
>>>> Printing Components, Email Components,
>>>> FTP Client Classes, Enhanced Data Controls, much more.
>>>> DSI PrintManager, Miradyne Component Libraries:
>>>> http://www.miradyne.net
>>>>
>>>> "tshad" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>>I am using asp.net 1.1 and am creating my pages with different looks
>>>>>and using controls for each part of the page (top, bottom, navigation
>>>>>etc)
>>>>>
>>>>> The way I have it set up is the following where I have 4 different
>>>>> controls (one for each page part). I am looking at a couple other
>>>>> ways of doing this as well and was wondering if there is a drawback to
>>>>> doing the others.
>>>>>
>>>>> *****************************************
>>>>> <%@ Page Language="VB" trace="false" debug="true"
>>>>> ContentType="text/html"
>>>>> ResponseEncoding="iso-8859-1" %>
>>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>>> <script runat="server">
>>>>> Sub Page_Load(sender as Object, e as EventArgs)
>>>>> Dim pageTop as String
>>>>> Dim navigateTop as String
>>>>> Dim pageBottom as String
>>>>> Dim pageTopControl as Control
>>>>> Dim navigateTopControl as Control
>>>>> Dim pageBottomControl as Control
>>>>> Dim LogonControl as Control
>>>>> Dim skinArray as ArrayList = Application("SkinArray")
>>>>>
>>>>> pageTop = "PageTop.ascx"
>>>>> navigateTop = "NavigateTop.ascx"
>>>>> pageBottom = "PageBottom.ascx"
>>>>>
>>>>> pageTopControl = LoadControl(pageTop)
>>>>> PageTopPanel.Controls.Add(pageTopControl)
>>>>> navigateTopControl = LoadControl(navigateTop)
>>>>> NavigateTopPanel.Controls.Add(navigateTopControl)
>>>>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>>>>> LogonPanel.Controls.Add(LogonControl)
>>>>> pageBottomControl = LoadControl(pageBottom)
>>>>> PageBottomPanel.Controls.Add(pageBottomControl)
>>>>> end Sub
>>>>> </script>
>>>>>
>>>>> <html>
>>>>> <head>
>>>>> <title>:: Staffing Workshop ::</title>
>>>>> <meta http-equiv="Content-Type" content="text/html;
>>>>> charset=iso-8859-1">
>>>>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>>>>> marginheight="0" runat="server">
>>>>> <form id="addForm" runat="server">
>>>>>
>>>>> <asplaceHolder ID="PageTopPanel" runat="server"/>
>>>>> <asplaceHolder ID="NavigateTopPanel" runat="server"/>
>>>>> <asplaceHolder ID="LogonPanel" runat="server"/>
>>>>> <asplaceHolder ID="PageBottomPanel" runat="server"/>
>>>>>
>>>>> </form>
>>>>> </body>
>>>>> </html>
>>>>> ******************************************
>>>>>
>>>>> Another way is to have only one Placeholder and load them one by one.
>>>>> Not sure if this would have any performance impact or not. I am still
>>>>> loading 4 pages. Would the controls always display in the order they
>>>>> are loaded into the PlaceHolder?
>>>>>
>>>>> *****************************************
>>>>> <%@ Page Language="VB" trace="false" debug="true"
>>>>> ContentType="text/html"
>>>>> ResponseEncoding="iso-8859-1" %>
>>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>>> <script runat="server">
>>>>> Sub Page_Load(sender as Object, e as EventArgs)
>>>>> Dim pageTop as String
>>>>> Dim navigateTop as String
>>>>> Dim pageBottom as String
>>>>> Dim pageTopControl as Control
>>>>> Dim navigateTopControl as Control
>>>>> Dim pageBottomControl as Control
>>>>> Dim LogonControl as Control
>>>>> Dim skinArray as ArrayList = Application("SkinArray")
>>>>>
>>>>> pageTop = "PageTop.ascx"
>>>>> navigateTop = "NavigateTop.ascx"
>>>>> pageBottom = "PageBottom.ascx"
>>>>>
>>>>> pageTopControl = LoadControl(pageTop)
>>>>> thePlaceHolder.Controls.Add(pageTopControl)
>>>>> navigateTopControl = LoadControl(navigateTop)
>>>>> thePlaceHolder.Controls.Add(navigateTopControl)
>>>>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>>>>> thePlaceHolder.Controls.Add(LogonControl)
>>>>> pageBottomControl = LoadControl(pageBottom)
>>>>> thePlaceHolder.Controls.Add(pageBottomControl)
>>>>> end Sub
>>>>> </script>
>>>>>
>>>>> <html>
>>>>> <head>
>>>>> <title>:: Staffing Workshop ::</title>
>>>>> <meta http-equiv="Content-Type" content="text/html;
>>>>> charset=iso-8859-1">
>>>>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>>>>> marginheight="0" runat="server">
>>>>> <form id="addForm" runat="server">
>>>>>
>>>>> <asplaceHolder ID="thePlaceHolder" runat="server"/>
>>>>>
>>>>> </form>
>>>>> </body>
>>>>> </html>
>>>>> ******************************************
>>>>>
>>>>> The other way is to just build the whole page and have that page as a
>>>>> control and have it just load the content section as a control
>>>>> (DisplayCompanyJobs.ascx in my example).
>>>>>
>>>>> Not sure if I would be saving a lot here as I am still loading a
>>>>> couple of pages.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Tom
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      08-01-2007
Sounds good and will keep them in mind.

I do similar things where I will keep my generic email page in my database
instead of a file on the disk.

Thanks,

Tom

"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi Tom,
>
> I can certainly see how you've arrived at the point you're at now. It is
> often necessary to create something before one is able to create the best
> possible thing, usually due to time constraints or conditions.
>
> I have done a similar type of project myself, and it does include
> PlaceHolders in various places in case of a need for special customization
> by a particular client, although it is a more generic type of solution,
> which doesn't include any content other than the client's content.
>
> In my own experience, I used a combination of several different design
> ideas and technologies. I used a basic HTML layout similar to that of
> CSSZenGarden.com, which is highly flexible using an external style sheet,
> but describes a layout "framework," if you will. I substituted ASP.Net
> Panels for most of the divs, allowing me to dynamically change the
> content, and a MasterPage for the overall layout. The MasterPage exposes
> the various Controls it contains as properties which can be accessed by
> any page being hosted in the MasterPage. The actual content of the pages
> comes from a database, which includes Membership and Role Provider data in
> addition to content data. Individual Panels can have different CSS classes
> assigned to them if necessary, and the Style Sheet can be replaced
> completely for different clients, so that the entire layout is more or
> less dynamic.
>
> Various parts of the MasterPage can be hidden or displayed on a
> Page-by-Page basis, and as I mentioned, many of the Panels in the
> MasterPage include PlaceHolders for special cases.
>
> Even now I can think of ways I might be able to improve the design, but I
> too have to work within constraints. For example, I could store the actual
> external Style Sheet in the database, and retrieve it with a special HTTP
> Handler. Perhaps I'll be able to implement some of these in the future. I
> don't know which of these options you may have already thought of, but
> those are a few ideas you may want to think about for the future.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
>
> Printing Components, Email Components,
> FTP Client Classes, Enhanced Data Controls, much more.
> DSI PrintManager, Miradyne Component Libraries:
> http://www.miradyne.net
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> You're right about the architecture.
>>
>> I wrote the original design about a year ago that I never got to. I
>> started working with the page and after finding out that I could just
>> move the <form> tags to just after the <body> tag without any problems,
>> that solved a lot of problems and questions. I was trying to determine
>> the goods and bads of various approaches.
>>
>> What we are doing is allowing our clients to have their own custom pages
>> with an area for our software which includes names, addresses, datagrids
>> of date etc. We need our own menus but will need to adjust the look
>> depending on the look of the page - controlled by CSS. In most cases,
>> the page will have a top, left and bottom page with our content going in
>> the middle-right section of the page. I already have it pretty much
>> working (with a couple of issues I found during testing the first few
>> pages and posted last night).
>>
>> The page looks like:
>> ************************************************** **************
>> <%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
>> ResponseEncoding="iso-8859-1" %>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>> <script runat="server">
>> Sub Page_Load(sender as Object, e as EventArgs)
>> Dim thePage as String
>> Dim pageControl as Control
>> Dim navigation as String
>> Dim contentControl as Control
>> Dim a as htmlControl
>> Dim skinArray as ArrayList = Application("SkinArray")
>> for i as integer = 0 to skinArray.Count - 1 step 3
>> if skinArray(i) = request("MID") then
>> session("CompanyInitials") = skinArray(i+1)
>> end if
>> Next
>> if not session("CompanyInitials") is Nothing then
>> thePage = "/skins/" & session("CompanyInitials") & "/" & "MainPage" &
>> ".ascx"
>> navigation = "NavigateTop" & ".ascx"
>> end if
>> pageControl = LoadControl(thePage)
>> thePlaceHolder.Controls.Add(pageControl)
>> contentControl =
>> CType(thePlaceHolder.FindControl("_ctl0:Navigation "),Control)
>> contentControl.Controls.Add(LoadControl(navigation ))
>> contentControl = CType(Page.FindControl("_ctl0:Content"),Control)
>>
>> contentControl.Controls.Add(LoadControl("/applicant/DisplayCompanyJobs.ascx"))
>>
>> end Sub
>>
>> </script>
>> <html>
>> <head>
>> <title>:: SW::</title>
>> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>> </head>
>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>> marginheight="0" runat="server">
>> <form id="addForm" runat="server">
>> <asplaceHolder ID="thePlaceHolder" runat="server"/>
>> </form>
>> </body>
>> </html>
>> ************************************************** **************
>>
>> As you can see, I have replaced the 4 controls with 1. This is the whole
>> page designed specifically for the client. I put 2 controls on this page
>> somewhere. Would be a different place for each (1 for content and 1 for
>> navigation menus/links). I then then load the 2 controls into these
>> controls.
>>
>> The other change I think I am going to make is to take all the asp.net
>> code and move it to a control and load that also. That way if I make any
>> changes to the code, I only have to make it in one place. I will
>> literally have 100+ identical pages with only the content control (which
>> would be different for each page) being different:
>>
>> contentControl = CType(Page.FindControl("_ctl0:Content"),Control)
>>
>> contentControl.Controls.Add(LoadControl("/applicant/DisplayCompanyJobs.ascx"))
>>
>> If there was a way to do this with one page that would be nice, but I
>> need a page for each page being called.
>>
>> This seems like it will work pretty well once I solve the problem with
>> the asp:HyperLink which doesn't seem to be working correctly, as I
>> mentioned in another post. Everything else seems to be working.
>>
>> I am sure there are other (and maybe better ways) but this seems pretty
>> clean and maintainable.
>>
>> Thanks,
>>
>> Tom
>>
>> "Kevin Spencer" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Hi Tom,
>>>
>>> I'm still thinking that there is something awry about your architecture.
>>> Skins are generally much simpler to use than you're describing. In fact,
>>> depending upon your requirements again, if all you're doing is changing
>>> the look of the page, this can be done for the most part using a CSS
>>> style sheet, and dynamic styles. But skins are okay, and come in handy
>>> from time to time. Still, as I said, the model for using them is simpler
>>> than what you're describing.
>>>
>>> Controls are dynamic by nature rather than static, so it still seems
>>> like you've got an extra layer of indirection with the Placeholders. I
>>> have found that many times in my experience I've stepped back after a
>>> number of changes, taken a fresh look at the architecture from my new
>>> viewpoint (having done some of the actual work), and decided to take a
>>> fresh approach to the issue. One common mistake I've seen, and I can't
>>> tell if you're actually making this one, is that developers will often
>>> take too much advantage of the dynamic nature of ASP.Net and make one
>>> page or one Control do too many things. A simpler, more modular approach
>>> is generally easier to maintain in the long run. But as I said, that's
>>> only a general observation, not necessarily applicable to your current
>>> situation.
>>>
>>> At any rate, in answer to your question regarding the order of loading
>>> of the PlaceHolders, yes, they will always appear in the order you place
>>> them in the Page.
>>>
>>> --
>>> HTH,
>>>
>>> Kevin Spencer
>>> Microsoft MVP
>>>
>>> Printing Components, Email Components,
>>> FTP Client Classes, Enhanced Data Controls, much more.
>>> DSI PrintManager, Miradyne Component Libraries:
>>> http://www.miradyne.net
>>>
>>> "tshad" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> "Kevin Spencer" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> It's kind of hard to advise you without knowing a bit more about your
>>>>> requirements and design. For example, from your code, I don't see why
>>>>> you're using all that logic to load the User Controls into the page,
>>>>> when you could just reference them with tags in the page markup.
>>>>
>>>> Each one of the Controls is a different part of the page, mainly html
>>>> code. The Content control has all the asp.net code with textboxes,
>>>> labels, datagrids etc.
>>>>
>>>> Each control is different for each client and the controls come from
>>>> different folders depending on the client. This is why the controls
>>>> are not static. The PageTop control could be
>>>> "skins\ft\displaypage.ascx" for one client and
>>>> "skins\jl\displaypage.ascx" for another. I am not showing the whole
>>>> code to make it simpler for my example. I would normally build the
>>>> Folders (skins\ft for example) based on a session variable.
>>>>
>>>> Originally, I had multiple controls because I was thinking that the
>>>> Forms tags need to be only around the Content Control (LogonControl ),
>>>> in my example.
>>>>
>>>> Now I find that I can put the Forms tag around all the controls without
>>>> any problems. So that being the case, I could just set up the 2nd
>>>> example (thePlaceHolder), which just houses all the controls. Not sure
>>>> if I am gaining anything here.
>>>>
>>>> The last case was just to have the whole page built for each client and
>>>> on each page are the controls I need (content and navigation mainly)
>>>> and just access the controls that way.
>>>>
>>>> Thanks,
>>>>
>>>> Tom
>>>>>
>>>>> --
>>>>> HTH,
>>>>>
>>>>> Kevin Spencer
>>>>> Microsoft MVP
>>>>>
>>>>> Printing Components, Email Components,
>>>>> FTP Client Classes, Enhanced Data Controls, much more.
>>>>> DSI PrintManager, Miradyne Component Libraries:
>>>>> http://www.miradyne.net
>>>>>
>>>>> "tshad" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>>I am using asp.net 1.1 and am creating my pages with different looks
>>>>>>and using controls for each part of the page (top, bottom, navigation
>>>>>>etc)
>>>>>>
>>>>>> The way I have it set up is the following where I have 4 different
>>>>>> controls (one for each page part). I am looking at a couple other
>>>>>> ways of doing this as well and was wondering if there is a drawback
>>>>>> to doing the others.
>>>>>>
>>>>>> *****************************************
>>>>>> <%@ Page Language="VB" trace="false" debug="true"
>>>>>> ContentType="text/html"
>>>>>> ResponseEncoding="iso-8859-1" %>
>>>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>>>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>>>> <script runat="server">
>>>>>> Sub Page_Load(sender as Object, e as EventArgs)
>>>>>> Dim pageTop as String
>>>>>> Dim navigateTop as String
>>>>>> Dim pageBottom as String
>>>>>> Dim pageTopControl as Control
>>>>>> Dim navigateTopControl as Control
>>>>>> Dim pageBottomControl as Control
>>>>>> Dim LogonControl as Control
>>>>>> Dim skinArray as ArrayList = Application("SkinArray")
>>>>>>
>>>>>> pageTop = "PageTop.ascx"
>>>>>> navigateTop = "NavigateTop.ascx"
>>>>>> pageBottom = "PageBottom.ascx"
>>>>>>
>>>>>> pageTopControl = LoadControl(pageTop)
>>>>>> PageTopPanel.Controls.Add(pageTopControl)
>>>>>> navigateTopControl = LoadControl(navigateTop)
>>>>>> NavigateTopPanel.Controls.Add(navigateTopControl)
>>>>>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>>>>>> LogonPanel.Controls.Add(LogonControl)
>>>>>> pageBottomControl = LoadControl(pageBottom)
>>>>>> PageBottomPanel.Controls.Add(pageBottomControl)
>>>>>> end Sub
>>>>>> </script>
>>>>>>
>>>>>> <html>
>>>>>> <head>
>>>>>> <title>:: Staffing Workshop ::</title>
>>>>>> <meta http-equiv="Content-Type" content="text/html;
>>>>>> charset=iso-8859-1">
>>>>>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>>>>>> marginheight="0" runat="server">
>>>>>> <form id="addForm" runat="server">
>>>>>>
>>>>>> <asplaceHolder ID="PageTopPanel" runat="server"/>
>>>>>> <asplaceHolder ID="NavigateTopPanel" runat="server"/>
>>>>>> <asplaceHolder ID="LogonPanel" runat="server"/>
>>>>>> <asplaceHolder ID="PageBottomPanel" runat="server"/>
>>>>>>
>>>>>> </form>
>>>>>> </body>
>>>>>> </html>
>>>>>> ******************************************
>>>>>>
>>>>>> Another way is to have only one Placeholder and load them one by one.
>>>>>> Not sure if this would have any performance impact or not. I am
>>>>>> still loading 4 pages. Would the controls always display in the
>>>>>> order they are loaded into the PlaceHolder?
>>>>>>
>>>>>> *****************************************
>>>>>> <%@ Page Language="VB" trace="false" debug="true"
>>>>>> ContentType="text/html"
>>>>>> ResponseEncoding="iso-8859-1" %>
>>>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>>>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>>>> <script runat="server">
>>>>>> Sub Page_Load(sender as Object, e as EventArgs)
>>>>>> Dim pageTop as String
>>>>>> Dim navigateTop as String
>>>>>> Dim pageBottom as String
>>>>>> Dim pageTopControl as Control
>>>>>> Dim navigateTopControl as Control
>>>>>> Dim pageBottomControl as Control
>>>>>> Dim LogonControl as Control
>>>>>> Dim skinArray as ArrayList = Application("SkinArray")
>>>>>>
>>>>>> pageTop = "PageTop.ascx"
>>>>>> navigateTop = "NavigateTop.ascx"
>>>>>> pageBottom = "PageBottom.ascx"
>>>>>>
>>>>>> pageTopControl = LoadControl(pageTop)
>>>>>> thePlaceHolder.Controls.Add(pageTopControl)
>>>>>> navigateTopControl = LoadControl(navigateTop)
>>>>>> thePlaceHolder.Controls.Add(navigateTopControl)
>>>>>> LogonControl = LoadControl("DisplayCompanyJobs.ascx")
>>>>>> thePlaceHolder.Controls.Add(LogonControl)
>>>>>> pageBottomControl = LoadControl(pageBottom)
>>>>>> thePlaceHolder.Controls.Add(pageBottomControl)
>>>>>> end Sub
>>>>>> </script>
>>>>>>
>>>>>> <html>
>>>>>> <head>
>>>>>> <title>:: Staffing Workshop ::</title>
>>>>>> <meta http-equiv="Content-Type" content="text/html;
>>>>>> charset=iso-8859-1">
>>>>>> <body id="myBody" leftmargin="0" topmargin="0" marginwidth="0"
>>>>>> marginheight="0" runat="server">
>>>>>> <form id="addForm" runat="server">
>>>>>>
>>>>>> <asplaceHolder ID="thePlaceHolder" runat="server"/>
>>>>>>
>>>>>> </form>
>>>>>> </body>
>>>>>> </html>
>>>>>> ******************************************
>>>>>>
>>>>>> The other way is to just build the whole page and have that page as a
>>>>>> control and have it just load the content section as a control
>>>>>> (DisplayCompanyJobs.ascx in my example).
>>>>>>
>>>>>> Not sure if I would be saving a lot here as I am still loading a
>>>>>> couple of pages.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
web user controls and placeholders cyndie woodster via DotNetMonster.com ASP .Net 1 03-02-2005 01:16 PM
Failed to load viewstate when dynamically adding controls in placeholders Sinisa Ruzin ASP .Net 0 10-07-2004 05:31 PM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net Building Controls 1 05-26-2004 06:41 AM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net 1 05-26-2004 12:42 AM
loading using controls into placeholders buran ASP .Net 1 04-06-2004 05:22 PM



Advertisments