views:

166

answers:

1

I have subclassed the ASP.NET Panel control to customise the rendering of the GroupingText. However, while it appears fine in the final output, it is not appearing correctly in the designer.

A sample of what I am doing follows:

Is there anything else I need to do to make it appear correctly in the designer?

Imports System.Web.UI

Public Class CustomPanel
    Inherits Panel

    Public Overrides Sub RenderBeginTag(ByVal writer As System.Web.UI.HtmlTextWriter)
        Me.AddAttributesToRender(writer)
        Dim tagKey As HtmlTextWriterTag = Me.TagKey
        If (tagKey <> HtmlTextWriterTag.Unknown) Then
            writer.RenderBeginTag(tagKey)
        Else
            writer.RenderBeginTag(Me.TagName)
        End If
        Dim groupingText As String = Me.GroupingText
        If ((groupingText.Length <> 0) AndAlso Not TypeOf writer Is Html32TextWriter) Then
            writer.AddAttribute("class", "heading")
            writer.RenderBeginTag(HtmlTextWriterTag.Div)
            writer.Write(groupingText)
            writer.RenderEndTag()
        End If
    End Sub

End Class
+1  A: 

You probably want to take a tour through the MSDN posting about "Adding Design Time Support to ASP.Net controls"

Just to let you know as well: creating custom server controls with robust design time support is not a trivial thing. If you can get away with using a UserControl, or dealing with the lack of design time support you are better off.

More often than not, this is an exercise that is better left to people who do this for a living.

Josh