473,786 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

server side include or user control?

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"
defaultcontenti d = 33
%>
<!--#include virtual="/include/mastertemplate. asp" -->

mastertemplate. asp would be the entire page, echoing and processing the
variables like so:

<!--#include virtual="/include/cmsfunctions.as p" -->
<body id="<%= pageid %>">
<%= cmsRenderConten t(defaultconten tid) %>

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
Nov 19 '05 #1
4 1819
TJS
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.loadcontro l method.

example:
------------------------
....somewhere in your code

' Dynamically inject a signin login module into the page
'---------------------------------------------------------------------
If Request.IsAuthe nticated = False Then
LoginControl.Co ntrols.Add(Page .LoadControl("~/SignIn.ascx"))
End If

..... somewhere in your template

<asp:placeholde r id="LoginContro l" runat="server" />
"Mark" <ma*****@yahoo. com> wrote in message
news:ma******** *************** ****@news.isp.g iganews.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"
defaultcontenti d = 33
%>
<!--#include virtual="/include/mastertemplate. asp" -->

mastertemplate. asp would be the entire page, echoing and processing the
variables like so:

<!--#include virtual="/include/cmsfunctions.as p" -->
<body id="<%= pageid %>">
<%= cmsRenderConten t(defaultconten tid) %>

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

Nov 19 '05 #2
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.g iganews.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"
defaultcontenti d = 33
%>
<!--#include virtual="/include/mastertemplate. asp" -->

mastertemplate. asp would be the entire page, echoing and processing the
variables like so:

<!--#include virtual="/include/cmsfunctions.as p" -->
<body id="<%= pageid %>">
<%= cmsRenderConten t(defaultconten tid) %>

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

Nov 19 '05 #3
In article <#3************ **@TK2MSFTNGP10 .phx.gbl>,
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> 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=1 23
/portfolio/index.aspx?id=4 56

I'll go

/index.aspx?s=ab out&id=123
/index.aspx?s=po rtfolio&id=456

This should work fine, especially since the cms has url aliasing.

Thnkas,
Nov 19 '05 #4
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.g iganews.com...
In article <#3************ **@TK2MSFTNGP10 .phx.gbl>,
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> 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=1 23
/portfolio/index.aspx?id=4 56

I'll go

/index.aspx?s=ab out&id=123
/index.aspx?s=po rtfolio&id=456

This should work fine, especially since the cms has url aliasing.

Thnkas,

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
12433
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, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server Side Form. I know I can use the context with to Response.redirect or Server.transfer to return a
2
8403
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 submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
11
1252
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 rk.aspnet&sMessageID=%253C7d8d01c3b4a1%2524412f7770% 2524a601280a@phx.gbl%253E The problem has not fixed till now.
6
2828
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?
20
5650
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 client-side HTML, CSS, etc. What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
3
1598
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 render. HISTORY I have an active website. I have about 100 include files that are just html text. In .aspx page, I have the following:
5
2459
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 made the postback request.???" for e.g. I have a webpage default.aspx. I place TWO or more server buttons on it. Create server-side event handlers for each of the buttons.
2
6968
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
0
9647
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9960
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.