Custom control help

Discussion in 'ASP .Net Web Controls' started by RajSurisetti, Apr 21, 2004.

  1. RajSurisetti

    RajSurisetti Guest

    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.
    RajSurisetti, Apr 21, 2004
    #1
    1. Advertising

  2. RajSurisetti

    RajSurisetti Guest

    (RajSurisetti) wrote in message news:<>...
    > 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
    RajSurisetti, Apr 23, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    705
  2. Jonah Olsson
    Replies:
    1
    Views:
    561
    Scott Allen
    Apr 5, 2005
  3. J R M
    Replies:
    2
    Views:
    415
    Charlie@CBFC
    Jun 1, 2006
  4. Matt Sokol
    Replies:
    2
    Views:
    364
    Theo Tillotson
    Aug 7, 2003
  5. Jonah Olsson
    Replies:
    2
    Views:
    186
    Jonah Olsson
    Apr 5, 2005
Loading...

Share This Page