【问题标题】:ASP.NET Panel subclass not appearing correctly in the DesignerASP.NET 面板子类未在设计器中正确显示
【发布时间】:2023-03-10 22:25:01
【问题描述】:

我已将 ASP.NET Panel 控件子类化以自定义 GroupingText 的呈现。然而,虽然它在最终输出中看起来不错,但在设计器中却没有正确显示。

我正在做的一个示例如下:

我还需要做些什么才能让它在设计器中正确显示吗?

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

【问题讨论】:

    标签: c# asp.net vb.net custom-controls panel


    【解决方案1】:

    您可能想浏览一下有关 "Adding Design Time Support to ASP.Net controls" 的 MSDN 帖子

    也让您知道:创建具有强大设计时支持的自定义服务器控件并非易事。如果您可以侥幸使用 UserControl,或者处理缺乏设计时支持的问题,那就更好了。

    通常情况下,这个练习最好留给people who do this for a living

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多