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

Custom control help

Hi,

Can anyone help me to build custom control for the following

<HEAD>
<LINK href="~/Styles/Blah.css" rel="stylesheet" type="text/css">
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content =
"http://schemas.microsoft.com/intellisense/ie5">
</HEAD>

to

<FW:Head id="myHead1" Style="~/Styles/Blah.css" Keyword="Blah"
runat="server"/>

I would apperiate any help i can get.

Regards,
RajSurisetti.
Nov 18 '05 #1
3 1556
ra***********@aeromech.usyd.edu.au (RajSurisetti) wrote in message news:<48**************************@posting.google. com>...
Hi,

Can anyone help me to build custom control for the following

<HEAD>
<LINK href="~/Styles/Blah.css" rel="stylesheet" type="text/css">
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content =
"http://schemas.microsoft.com/intellisense/ie5">
</HEAD>

to

<FW:Head id="myHead1" Style="~/Styles/Blah.css" Keyword="Blah"
runat="server"/>

I would apperiate any help i can get.

Regards,
RajSurisetti.


This is code

using System;
using System.ComponentModel;
using System.Web.UI;

namespace myNameSpace{
[
DefaultProperty("Stylesheet")
]
/// <remarks>
/// Creates a Head element in HTML with the appropriate attributes as
required by the framework.
/// </remarks>
public class Head : Control, INamingContainer
{
[
Category("Behavior"),
DefaultValue(""),
Description("The html head tag generator for the framework")
]
#region Internal Properties
private String sKeywords = "";
private String sStylesheet = "";
#endregion
#region Properties
public String Keywords
{
get
{
return sKeywords;
}
set
{
sKeywords = value;
}
}

public String Stylesheet
{
get
{
return sStylesheet;
}
set
{
sStylesheet = value;
}
}
#endregion
#region Overrides
// This ensures that there are no child controls.
protected override ControlCollection CreateControlCollection()
{
return new EmptyControlCollection(this);
}
protected override void Render(HtmlTextWriter writer)
{
writer.RenderBeginTag(HtmlTextWriterTag.Head);
if(sStylesheet.Length != 0)
{
writer.AddAttribute( "rel", "stylesheet", false);
writer.AddAttribute( "type", "text/css", false);
writer.AddAttribute( "href", sStylesheet, true);
writer.RenderBeginTag(HtmlTextWriterTag.Link);
writer.RenderEndTag();
}
if(sKeywords.Length != 0)
{
writer.AddAttribute( "name", "keywords", false);
writer.AddAttribute( "content", sKeywords, true);
writer.RenderBeginTag(HtmlTextWriterTag.Meta);
writer.RenderEndTag();
}
writer.RenderEndTag();
}
#endregion
}
}
cheers,
RajSurisetti
Nov 18 '05 #2
Hello ra***********@aeromech.usyd.edu.au,

If I'm not mistaken, this code will write out in this format...

<html>
<body>
<head>...</head>
</body>
</html>

instead of the expected format where <head>...</head> would be a child of <html>.

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #3
Matt Berther <mb******@hotmail.com> wrote in message news:<#$**************@TK2MSFTNGP11.phx.gbl>...
Hello ra***********@aeromech.usyd.edu.au,

If I'm not mistaken, this code will write out in this format...

<html>
<body>
<head>...</head>
</body>
</html>

instead of the expected format where <head>...</head> would be a child of <html>.


Hi Matt,

<FW:Head id="myHead1" Style="~/Styles/Blah.css" Keyword="Blah"
runat="server"/>

Generated HTML code

<HEAD>
<LINK href="~/Styles/Blah.css" rel="stylesheet" type="text/css">
<meta name="Keyword" Content="Blah">
</HEAD>

you can add as many meta tags you want.
I used same logic for Breadcrumbs and it worked fine.

----------------------
Hope this is helpful.
RajSurisetti.
Nov 18 '05 #4

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

Similar topics

8
by: Tinus | last post by:
Hello all, I've create a custom control (UserControl) and have a custom Item Collection. The control is a custom calendar which is draw using the Graphics Rectangle etc. functions. It is drawn...
15
by: Tinus | last post by:
Hello all, I've created a custom control that draws a monthly schedule (using the Draw function in C#). Basically it draws 31 boxes and writes the day number in every box. This works...
21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
5
by: Alan Silver | last post by:
Hello, I have a products page that takes a product ID in the query string. Based on the product details (from a database), the page then loads up one of a number of custom controls, calls a...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
2
by: ahmed.maryam | last post by:
Hello Everyone, I designed a custom control that is entirely covered by a picture box. I then dragged this custom control onto a windows form application (called main) and I need to handle mouse...
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
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...

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.