473,652 Members | 3,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inherit from System.Web.UI.H tmlControls ?

Hi folks,

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,Ve rdana,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.h tmlcontrols.Htm lContainerContr ol

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
Me.EnableViewSt ate = False
End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim headerControl As System.Web.UI.W ebControls.Plac eHolder =
Page.FindContro l("_head")
if not isNothing(heade rControl) then
Dim newStyle As New
System.Web.UI.H tmlControls.Htm lGenericControl
newStyle.TagNam e = "STYLE"
newStyle.InnerT ext = Me.InnerHtml
headerControl.C ontrols.Add(new Style)
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.h tmlcontrols because they break the HTML Control Model. But I
have to inherit from this class because of the use of tge "innerHTML"
property in my code.

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

Thanks

Jill
Jul 21 '05 #1
0 1352

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

Similar topics

0
1247
by: Matrix - MAM | last post by:
I'm using the following code in my Web Application. private void Button1_Click(object sender, System.EventArgs e) { //sourceFile is id of System.Web.UI.HtmlControls.HtmlInputFile if(sourceFile.PostedFile != null) { string location = @"C\Temp\"; string fn = System.IO.Path.GetFileName(sourceFile.PostedFile.FileName); sourceFile.PostedFile.SaveAs(location + "test.txt"); }
6
2907
by: Mohammad-Reza | last post by:
I wrote a component using class library wizard. In my component i want to in order to RightToLeft property do some works. I can find out if user set this property to Yes or No, But if He/She set it to Inherit I must examine its parent RightToLeft property(if i`m wrong please tell me) but in this component that inherits from System.ComponentModel.Component, How can i find parent??? In UserControls we can simply use Parent property but in...
3
4584
by: Jill Graham | last post by:
Hi folks, 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>
10
12216
by: tshad | last post by:
I have a problem setting the background color of textbox on the fly. I tried using: applicantID.backcolor = "F6F6F6" and applicantID.backcolor = "#F6F6F6"
2
2660
by: Sean Carey | last post by:
I converted a C# Upload app to VB.NET and am down to one error and was hoping someone could help me with te error. I would greatly appreciate help from anyone. Here is the error: c:\inetpub\wwwroot\admin\filemanager.aspx.vb(76): Expression is of type 'System.Web.UI.HtmlControls.HtmlInputFile', which is not a collection type.
0
292
by: Jill Graham | last post by:
Hi folks, 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>
8
1855
by: Nathan Sokalski | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. After the file is successfully submitted, I want the field to be reset so that the user knows the file was submitted. However, ASP.NET does not let you change the Value property of an HtmlInputFile control. How can I reset the HtmlInputFile control to it's original state? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
3
8927
by: J | last post by:
I tried to inherit 'Shot' class from 'Image' class, only to fail. It gives me the CS0122 error, which says that it can't access 'System.Drawing.Image.Image()'. What am I missing? using System;
9
2182
by: Arpan | last post by:
If I am not wrong, System.IO is one of the seven namespaces that get imported in all ASP.NET page automatically but in the following code: <%@ Import Namespace="System.IO" %> <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp") lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>" lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
0
8279
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
8589
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
7302
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...
1
6160
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
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...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1591
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.