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