I am setting up an asp.net site using the Ektron CMS. Every page in the
site uses the same basic template, with the look of the page changing
via CSS and an id on the body. The id is shared by all pages in a
subsection, e.g. everything in /about/ needs to have <body id="about">.
In the past what I've done is set a global variable in index.asp, then
include the template to render the page:
<%
pageid = "about"
defaultcontentid = 33
%>
<!--#include virtual="/include/mastertemplate.asp" -->
mastertemplate.asp would be the entire page, echoing and processing the
variables like so:
<!--#include virtual="/include/cmsfunctions.asp" -->
<body id="<%= pageid %>">
<%= cmsRenderContent(defaultcontentid) %>
This worked great. I needed one index.asp for each subsection, and had
no duplication of template code. If the template needed to be updated, I
just gave it to the designer, who modified it in Dreamweaver or
whatever. The separation between presentation and logic was good, and
any code that generated html was in an easily-modified function.
I've experimented with a similar approach in asp.net, and have the start
of it working, but the additional complication is that
mastertemplate.aspx has some codebehind related to the cms server
controls that it uses, and I need to use the passed-in variables within
that codebehind. For example, I'd establish a default content id in the
calling page, and if the mastertemplate.asp doesn't detect an id in the
url, it will use the default.
I am looking for examples of this approach in asp.net but I keep running
across advice to use user controls instead. But it seems like user
controls are used for parts of pages, not the page template itself. Is
that right? Can a user control contain server controls? How would I pass
variables from a "stub" calling page to the user control page? Can a
user control be modified in something like Dreamweaver?
Thanks,
--
mark 4 1791
generally they are right.
You will typically put a "place holder" into the template and then replace
that "place holder" with content created from a control (.ascx file). the
content is injected into the position of the "place holder" by using the
page.loadcontrol method.
example:
------------------------
....somewhere in your code
' Dynamically inject a signin login module into the page
'---------------------------------------------------------------------
If Request.IsAuthenticated = False Then
LoginControl.Controls.Add(Page.LoadControl("~/SignIn.ascx"))
End If
..... somewhere in your template
<asp:placeholder id="LoginControl" runat="server" />
"Mark" <ma*****@yahoo.com> wrote in message
news:ma***************************@news.isp.gigane ws.com... I am setting up an asp.net site using the Ektron CMS. Every page in the site uses the same basic template, with the look of the page changing via CSS and an id on the body. The id is shared by all pages in a subsection, e.g. everything in /about/ needs to have <body id="about">.
In the past what I've done is set a global variable in index.asp, then include the template to render the page:
<% pageid = "about" defaultcontentid = 33 %> <!--#include virtual="/include/mastertemplate.asp" -->
mastertemplate.asp would be the entire page, echoing and processing the variables like so:
<!--#include virtual="/include/cmsfunctions.asp" --> <body id="<%= pageid %>"> <%= cmsRenderContent(defaultcontentid) %>
This worked great. I needed one index.asp for each subsection, and had no duplication of template code. If the template needed to be updated, I just gave it to the designer, who modified it in Dreamweaver or whatever. The separation between presentation and logic was good, and any code that generated html was in an easily-modified function.
I've experimented with a similar approach in asp.net, and have the start of it working, but the additional complication is that mastertemplate.aspx has some codebehind related to the cms server controls that it uses, and I need to use the passed-in variables within that codebehind. For example, I'd establish a default content id in the calling page, and if the mastertemplate.asp doesn't detect an id in the url, it will use the default.
I am looking for examples of this approach in asp.net but I keep running across advice to use user controls instead. But it seems like user controls are used for parts of pages, not the page template itself. Is that right? Can a user control contain server controls? How would I pass variables from a "stub" calling page to the user control page? Can a user control be modified in something like Dreamweaver?
Thanks,
-- mark
Include files are old fashioned.
User controls are a better approach. Yes, they can contain any kind of
controls you'd like. You can create public properties, methods, and events
to facilitate communication between the user control and the page.
I agree with you that user controls do not fully achieve the "template"
functionality you seek as gracefully as we'd all like, but the only great
solution is in ASP.NET 2.0 (due out later this year) which implements
"Master Pages".
Here's more info: http://SteveOrr.net/faq/usercustom.aspx http://www.c-sharpcorner.com/Code/20...asterPages.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Mark" <ma*****@yahoo.com> wrote in message
news:ma***************************@news.isp.gigane ws.com... I am setting up an asp.net site using the Ektron CMS. Every page in the site uses the same basic template, with the look of the page changing via CSS and an id on the body. The id is shared by all pages in a subsection, e.g. everything in /about/ needs to have <body id="about">.
In the past what I've done is set a global variable in index.asp, then include the template to render the page:
<% pageid = "about" defaultcontentid = 33 %> <!--#include virtual="/include/mastertemplate.asp" -->
mastertemplate.asp would be the entire page, echoing and processing the variables like so:
<!--#include virtual="/include/cmsfunctions.asp" --> <body id="<%= pageid %>"> <%= cmsRenderContent(defaultcontentid) %>
This worked great. I needed one index.asp for each subsection, and had no duplication of template code. If the template needed to be updated, I just gave it to the designer, who modified it in Dreamweaver or whatever. The separation between presentation and logic was good, and any code that generated html was in an easily-modified function.
I've experimented with a similar approach in asp.net, and have the start of it working, but the additional complication is that mastertemplate.aspx has some codebehind related to the cms server controls that it uses, and I need to use the passed-in variables within that codebehind. For example, I'd establish a default content id in the calling page, and if the mastertemplate.asp doesn't detect an id in the url, it will use the default.
I am looking for examples of this approach in asp.net but I keep running across advice to use user controls instead. But it seems like user controls are used for parts of pages, not the page template itself. Is that right? Can a user control contain server controls? How would I pass variables from a "stub" calling page to the user control page? Can a user control be modified in something like Dreamweaver?
Thanks,
-- mark
In article <#3**************@TK2MSFTNGP10.phx.gbl>,
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote: I agree with you that user controls do not fully achieve the "template" functionality you seek as gracefully as we'd all like, but the only great solution is in ASP.NET 2.0 (due out later this year) which implements "Master Pages".
Here's more info: http://SteveOrr.net/faq/usercustom.aspx http://www.c-sharpcorner.com/Code/20...asterPages.asp
Yes, Master Pages is most like what I was after. Now I am thinking about
just passing the section name in the url and have everything run through
a single page. Instead of
/about/index.aspx?id=123
/portfolio/index.aspx?id=456
I'll go
/index.aspx?s=about&id=123
/index.aspx?s=portfolio&id=456
This should work fine, especially since the cms has url aliasing.
Thnkas,
Yes, I've tried that approach before and it's not as easy as it might seem
at first.
Since everything is essentially a postback to the same page, this opens up
new hassles related to dynamically creating controls at runtime and managing
them all between postbacks and keeping them from conflicting with eachother
in various ways.
If you can, skip to ASP.NET 2.0 and use master pages. Otherwise I'd suggest
you use multiple pages with header and/or footer controls to help manage a
common look & feel.
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://SteveOrr.net
"Mark" <ma*****@yahoo.com> wrote in message
news:ma***************************@news.isp.gigane ws.com... In article <#3**************@TK2MSFTNGP10.phx.gbl>, "Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote:
I agree with you that user controls do not fully achieve the "template" functionality you seek as gracefully as we'd all like, but the only great solution is in ASP.NET 2.0 (due out later this year) which implements "Master Pages".
Here's more info: http://SteveOrr.net/faq/usercustom.aspx http://www.c-sharpcorner.com/Code/20...asterPages.asp
Yes, Master Pages is most like what I was after. Now I am thinking about just passing the section name in the url and have everything run through a single page. Instead of
/about/index.aspx?id=123 /portfolio/index.aspx?id=456
I'll go
/index.aspx?s=about&id=123 /index.aspx?s=portfolio&id=456
This should work fine, especially since the cms has url aliasing.
Thnkas, This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: HarveyB |
last post by:
I would like to generate non-modal popup windows from
ASP.Net code-behind. I have tried using Client Side
scripting like "function Test(){
window.open('test.htm',_blank,...
|
by: Hazzard |
last post by:
I just realized that the code I inherited is using all asp.net server
controls (ie. webform controls) and when I try to update textboxes on the
client side, I lose the new value of the textbox when...
|
by: Tom |
last post by:
Hi all,
I posted the same question one week ago in
http://communities.microsoft.com/newsgroups/previewFrame.as
p?
ICP=msdn&sLCID=us&sgroupURL=microsoft.public.dotnet.framewo...
|
by: Tim Westmoreland |
last post by:
Can someone tell me how to raise an event or trap when the maxlength of a
server side textbox has been reached?
|
by: Guadala Harry |
last post by:
In an ASCX, I have a Literal control into which I inject a
at runtime.
litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID);
This works great as long as the contains just...
|
by: Larry |
last post by:
Hi,
I need a method to dynamically include a server side include in my
asp.net page. The problem is, the include file contains asp.net
controls, and I can't find a way to get the controls to...
|
by: mayur_hirpara |
last post by:
Hi,
I have been developing web applications for a while now.
However, as I was thinking through the architecture I really don't
understand the "How server can identify between which buttons has...
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |