Search code examples
c#asp.nethtmlmarquee

How can I create a marquee in asp.net c# codebehind?


I would like to create a marquee control in C# codebehind. How can I do that? I tried:

marqueetd.Controls.Add (new System.Web.UI.HtmlControls.

where marqueetd is the id of the td in which I want to add my marquee control.

However, there is no marquee control after HtmlControls.! Do you have any idea how I can do this, or is there any way to tag code the marquee in my aspx page and only add the text from codebehind?


Solution

  • You can create a generic control with the appropriate tag name:

    var control = new HtmlGenericControl( "marquee" );
    marqueetd.Controls.Add ( control );
    
    // set some properties/attributes
    control.Attributes["foo"] = "bar";
    control.InnerHtml = "<span>Some HTML</span>";
    

    Obligatory disclaimer: marquee is deprecated; marquee annoys people.