Annoying span

Discussion in 'ASP .Net Building Controls' started by Banski, Sep 2, 2004.

  1. Banski

    Banski Guest

    Hi,

    Ive a annoying problem when creating Custom WebControl.
    When i create this sample control in codebehind. It renders as:
    <span id="testctrl"><input name="testctrl:testctrl"
    id="testctrl_testctrl" type="text" value="TestValue" /></span>

    Why does it render <span> tags? How can I create it without them?

    Best regards
    Banski


    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Drawing;
    using System.Collections;
    using System.Text;

    namespace Conte.WebControls
    {
    /// <summary>
    /// Summary description for TestControl.
    /// </summary>
    public class TestControl : System.Web.UI.WebControls.WebControl,
    INamingContainer
    {

    public string Value
    {
    get { return htmlInputTxt.Value ; }
    set { htmlInputTxt.Value = value; }
    }


    HtmlInputButton htmlInputBtn;
    HtmlInputText htmlInputTxt;


    protected override void CreateChildControls()
    {
    htmlInputTxt = new HtmlInputText();
    htmlInputTxt.ID = base.ID;
    htmlInputTxt.Name = base.ID;
    htmlInputTxt.Value = "TestValue";
    Controls.Add(htmlInputTxt);

    }
    }
    }
     
    Banski, Sep 2, 2004
    #1
    1. Advertising

  2. you have to override RenderBeginTag and RenderEndTag of your WebControl

    also have a look at TagKey and TagName properties

    HTH
    Konrad Rotuski

    "Banski" <> wrote in message
    news:...
    > Hi,
    >
    > Ive a annoying problem when creating Custom WebControl.
    > When i create this sample control in codebehind. It renders as:
    > <span id="testctrl"><input name="testctrl:testctrl"
    > id="testctrl_testctrl" type="text" value="TestValue" /></span>
    >
    > Why does it render <span> tags? How can I create it without them?
    >
    > Best regards
    > Banski
    >
    >
    > using System;
    > using System.Web.UI;
    > using System.Web.UI.WebControls;
    > using System.ComponentModel;
    > using System.Web.UI.HtmlControls;
    > using System.IO;
    > using System.Drawing;
    > using System.Collections;
    > using System.Text;
    >
    > namespace Conte.WebControls
    > {
    > /// <summary>
    > /// Summary description for TestControl.
    > /// </summary>
    > public class TestControl : System.Web.UI.WebControls.WebControl,
    > INamingContainer
    > {
    >
    > public string Value
    > {
    > get { return htmlInputTxt.Value ; }
    > set { htmlInputTxt.Value = value; }
    > }
    >
    >
    > HtmlInputButton htmlInputBtn;
    > HtmlInputText htmlInputTxt;
    >
    >
    > protected override void CreateChildControls()
    > {
    > htmlInputTxt = new HtmlInputText();
    > htmlInputTxt.ID = base.ID;
    > htmlInputTxt.Name = base.ID;
    > htmlInputTxt.Value = "TestValue";
    > Controls.Add(htmlInputTxt);
    >
    > }
    > }
    > }
     
    Konrad Rotuski, Sep 2, 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. Fulio Open

    Can span include span?

    Fulio Open, Jun 26, 2009, in forum: HTML
    Replies:
    5
    Views:
    581
    dorayme
    Jun 26, 2009
  2. Stéphane Klein
    Replies:
    2
    Views:
    1,866
    John Nagle
    Mar 30, 2010
  3. Stefan Behnel
    Replies:
    0
    Views:
    507
    Stefan Behnel
    Mar 29, 2010
  4. Dan Bishop

    DataGrid (body only) contained in <span>...</span> tags

    Dan Bishop, Jun 7, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    308
    Kilic Beg
    Jun 7, 2004
  5. Wang, Jay
    Replies:
    5
    Views:
    525
    Wang, Jay
    May 25, 2004
Loading...

Share This Page