Re: Multiple Placeholders or One to load controls

Tech-Archive recommends: Fix windows errors by optimizing your registry



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" <t@xxxxxxxx> wrote in message
news:uZFB7ev0HHA.5152@xxxxxxxxxxxxxxxxxxxxxxx
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">

<asp:PlaceHolder ID="PageTopPanel" runat="server"/>
<asp:PlaceHolder ID="NavigateTopPanel" runat="server"/>
<asp:PlaceHolder ID="LogonPanel" runat="server"/>
<asp:PlaceHolder 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">

<asp:PlaceHolder 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





.



Relevant Pages

  • Multiple Placeholders or One to load controls
    ... Dim navigateTop as String ... Dim pageBottom as String ... Dim navigateTopControl as Control ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Multiple Placeholders or One to load controls
    ... The Content control has all the asp.net code with textboxes, labels, ... Dim pageTop as String ... Dim navigateTop as String ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IE sequencing and cookie notification popups
    ... ' 10Apr04: accept cookies from hotmail. ... Dim SetWindowLong ' as object ... Const sDlgCaption = " Kookie Kruncher, ... ' notifications associated with that type of control. ...
    (microsoft.public.scripting.vbscript)
  • FYI: TS client script
    ... for TS on the machine running the script, ... the web control class was not found; ... Dim m_Tracing, m_TraceStream ... Function ArgString(ByVal argName, ByVal defaultValue) ...
    (microsoft.public.win2000.termserv.clients)
  • FYI: TS client script
    ... for TS on the machine running the script, ... the web control class was not found; ... Dim m_Tracing, m_TraceStream ... Function ArgString(ByVal argName, ByVal defaultValue) ...
    (microsoft.public.windows.terminal_services)