WebControl SPAN tag
-
I am creating a custom WebControl. I noticed that it wraps everything in a SPAN tag. How can I get rid of this tag? I don’t want it to appear!
Excellence is not an act, but a habit!
Aristotle
-
I am creating a custom WebControl. I noticed that it wraps everything in a SPAN tag. How can I get rid of this tag? I don’t want it to appear!
Excellence is not an act, but a habit!
Aristotle
Override the constructor of the web control and pass in a string representing the tag you want it to be rendered as:
")> _ _ Public Class TestControl Inherits WebControl Public Sub New() MyBase.New("div") End Sub Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter) writer.Write("Time Now: " & Date.Now) End Sub End Class
Hope this helps Tom -
Override the constructor of the web control and pass in a string representing the tag you want it to be rendered as:
")> _ _ Public Class TestControl Inherits WebControl Public Sub New() MyBase.New("div") End Sub Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter) writer.Write("Time Now: " & Date.Now) End Sub End Class
Hope this helps TomYes, this allows me to change the tag. But I dont want it changed. I want it completely removed.
Excellence is not an act, but a habit!
Aristotle
-
Yes, this allows me to change the tag. But I dont want it changed. I want it completely removed.
Excellence is not an act, but a habit!
Aristotle
Override the RenderBeginTag and RenderEndTag and just don't call the base method:
Public Class TestControl Inherits WebControl Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter) writer.Write("Time Now: " & Date.Now) End Sub Public Overrides Sub RenderBeginTag(ByVal writer As System.Web.UI.HtmlTextWriter) 'MyBase.RenderBeginTag(writer) End Sub Public Overrides Sub RenderEndTag(ByVal writer As System.Web.UI.HtmlTextWriter) 'MyBase.RenderEndTag(writer) End Sub End Class
Hope this helps Tom