473,408 Members | 1,867 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,408 software developers and data experts.

How to accomplish this ?

Hi,

The pages of my website are built dynamically and are based on templates.

A template can look like this :

<table>
<tr><td>This is the page header</td></tr>
<tr><td>This is the page content</td></tr>
<tr><td>This is the page footer</td></tr>
</table>

People can modify the templates to suit their needs.

My problem is as follows :
Some people, when modifying the template, want to add some style definitions
using <STYLE>...</STYLE> and these style definitions should be put in the
heading of the page (<head>...</head> section).

To accomplish this, I've written a custom control (named "style") which will
copy the style section from the template to the page header.
The template now looks like this :

<emc:style runat="server">
<style>
.content {font-family:Arial,Verdana,Sans-serif; color:#ff0000;
font-size:10px;}
</style>
</emc:style>
<table>
<tr><td>This is the page header</td></tr>
<tr><td class="content">This is the page content</td></tr>
<tr><td>This is the page footer</td></tr>
</table>

Once the custom "style" control is executed, its "innerhtml" property (the
<style> itself) is read and copied to the pages header.
Here is the VB code for the custom "style" control :

Public Class Style
Inherits System.Web.UI.htmlcontrols.HtmlContainerControl

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
Me.EnableViewState = False
End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim headerControl As System.Web.UI.WebControls.PlaceHolder =
Page.FindControl("_head")
if not isNothing(headerControl) then
Dim newStyle As New
System.Web.UI.HtmlControls.HtmlGenericControl
newStyle.TagName = "STYLE"
newStyle.InnerText = Me.InnerHtml
headerControl.Controls.Add(newStyle)
newStyle = nothing
end if
headerControl = nothing

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
End Sub
End Class
This works fine ! However, I just read in a book from MS Press that we
should NEVER write a custom control that inherits from
System.Web.UI.htmlcontrols because they break the HTML Control Model.

Can anybody help me out here ? Is there another solution for this ?

Thanks


Nov 22 '05 #1
0 918

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

Similar topics

2
by: flamesrock | last post by:
Certain web applications, everything from wget to downloader for X has this nifty feature I'd like to accomplish in python. Its the progress bar/time elapsed/time remaining scheme Filename |...
4
by: Danny | last post by:
I am tyring to find the site, but I am seeing more and more web sites with the really long html names and also nicely broken down by category that sits on a related directory and/or subdomain on...
0
by: Jill Graham | last post by:
Hi, The pages of my website are built dynamically and are based on templates. A template can look like this : <table> <tr><td>This is the page header</td></tr> <tr><td>This is the page...
2
by: Julia Briggs | last post by:
Ok, here is the scenario -- I have a pop-up window that has some form data, information etc... and I want that window to close and re-direct the page on the original, main window that the user...
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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...
0
isladogs
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...
0
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...

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.