473,394 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to inclue ASP tags inside .CS file?

Hello friends,

I am new to ASP.NET. I have been working in c#.net. I want to modularize the
ASP program. for ex, the header part is always commom at the web pages, and i
do not want to write the same header code for all the files. Instead i want
to put the header code at a commom function/subroutine and on the page's load
event, would want to invoke these functions. Please suggest how to accomplish
this with a small sample program.

Thanks a lot.
Nov 19 '05 #1
2 1237
Indiresh wrote:
Hello friends,

I am new to ASP.NET. I have been working in c#.net. I want to
modularize the ASP program. for ex, the header part is always commom
at the web pages, and i do not want to write the same header code for
all the files. Instead i want to put the header code at a commom
function/subroutine and on the page's load event, would want to
invoke these functions. Please suggest how to accomplish this with a
small sample program.

Thanks a lot.


Do you mean code inside the <head> section or a visible header?

<head> section:
Define a <asp:Literal> at the correct position. Give that literal-control
to your library method, so it can be filled.

visible header:
use an ascx where you define your header, place that (ascx) on every page.

Hans Kesting
Nov 19 '05 #2
There are a couple of ways to kill this bird:

1. Create a user control for the header and drag on each page. A bit tedious
perhaps. If you only have one level, it is easy to save this as a template;
if you nest your site into directories, you will end up fixing broken control
references each time you nest lower (or making multiple templates for
different levels).

2. Create a server control for the header and create a new page template
that uses the server control. This is even easier, as you now have a template
for creating new pages. This requires learning how to do a server control,
but is easy once developed. Note that changes in "chrome" (look and feel)
require recompile of the server control.

3. Use ASP.NET 2.0 and use master pages. Easy, but requires moving to 2.0.

4. Use FrontPage 2003 web templates or Dreamweaver web templates for the
common elements and edit common elements in these programs only. This
actually places the HTML in each page. Requires a separate program for
design, but is fairly simple to maintain.

5. Create a base page class that uses an HTML Writer to output the header
information and inherit from that class. The trick here is making sure the
common elements end up in the right spot, which will either require the ASPX
page to talk to the base class or you will have to completely control the
entire page framework. If you go route 2, you will not be able to use the VS
designer for your pages (yuck) and route 1 will not show up in the designer
(may also be yuck).
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Indiresh" wrote:
Hello friends,

I am new to ASP.NET. I have been working in c#.net. I want to modularize the
ASP program. for ex, the header part is always commom at the web pages, and i
do not want to write the same header code for all the files. Instead i want
to put the header code at a commom function/subroutine and on the page's load
event, would want to invoke these functions. Please suggest how to accomplish
this with a small sample program.

Thanks a lot.

Nov 19 '05 #3

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

Similar topics

8
by: Fazer | last post by:
Hello, I was wondering what would be the easiest way to strip away HTML tags from a string? Or how would I remove everything between < and > also the < , > as well using regex? Thanks for...
3
by: jjliu | last post by:
Could someone tell me how to parse the inside of html tags by perl, such as <meta> </meta> <head> </head> <title> </title> ......... Thanks
5
by: ma.giorgi | last post by:
hi to all! I've tried in all the way but I can't find a solution I show you an example: I have the following html code: <div id="aaa">text inside<br/> a div</div><span class="bbb"> text inside...
23
by: Big Bill | last post by:
http://www.promcars.co.uk/pages/bonnie.php I don't believe they should be there, can I take them out without stopping the includes from functioning? I'm the (hapless) optimiser on this one... I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
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...
0
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,...
0
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...
0
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...
0
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...

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.