Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Custom control help

Reply
Thread Tools

Custom control help

 
 
RajSurisetti
Guest
Posts: n/a
 
      04-21-2004
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.
 
Reply With Quote
 
 
 
 
RajSurisetti
Guest
Posts: n/a
 
      04-23-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (RajSurisetti) wrote in message news:<(E-Mail Removed). 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom control within a custom control J R M ASP .Net 2 06-01-2006 06:04 PM
Capturing event from other custom control within another custom control Jonah Olsson ASP .Net 1 04-05-2005 01:39 PM
Capturing event from other custom control within another custom control Jonah Olsson ASP .Net Web Controls 2 04-05-2005 12:56 PM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net 0 07-01-2003 09:26 PM



Advertisments