ra***********@a eromech.usyd.ed u.au (RajSurisetti) wrote in message news:<48******* *************** ****@posting.go ogle.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="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema" content =
"http://schemas.microso ft.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.Componen tModel;
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, INamingContaine r
{
[
Category("Behav ior"),
DefaultValue("" ),
Description("Th e 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 ControlCollecti on CreateControlCo llection()
{
return new EmptyControlCol lection(this);
}
protected override void Render(HtmlText Writer writer)
{
writer.RenderBe ginTag(HtmlText WriterTag.Head) ;
if(sStylesheet. Length != 0)
{
writer.AddAttri bute( "rel", "stylesheet ", false);
writer.AddAttri bute( "type", "text/css", false);
writer.AddAttri bute( "href", sStylesheet, true);
writer.RenderBe ginTag(HtmlText WriterTag.Link) ;
writer.RenderEn dTag();
}
if(sKeywords.Le ngth != 0)
{
writer.AddAttri bute( "name", "keywords", false);
writer.AddAttri bute( "content", sKeywords, true);
writer.RenderBe ginTag(HtmlText WriterTag.Meta) ;
writer.RenderEn dTag();
}
writer.RenderEn dTag();
}
#endregion
}
}
cheers,
RajSurisetti