Annoying span

B

Banski

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);

}
}
}
 
K

Konrad Rotuski

you have to override RenderBeginTag and RenderEndTag of your WebControl

also have a look at TagKey and TagName properties

HTH
Konrad Rotuski
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top