开发者

asp.net custom server control design time support

开发者 https://www.devze.com 2022-12-16 13:45 出处:网络
I\'m having issues with a custo开发者_开发知识库m panel control in design view.Overriding the render method has no affect at design-time.

I'm having issues with a custo开发者_开发知识库m panel control in design view. Overriding the render method has no affect at design-time.

If I extend a textbox as follows the design time showed the div tag and then the textbox control. Tried the same with the panel control and it did not show the div with the here text in it. Seems since panel is a container control it works differently in design view. Really frustrating. Any ideas on how to get my design-time to render the way I want it to?

Public Class textboxextend
  Inherits TextBox

  Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

    writer.RenderBeginTag("div")
    writer.Write("here")
    writer.RenderEndTag()
    MyBase.Render(writer)
  End Sub
End Class

Public Class panelextend
  Inherits Panel

  Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

    writer.RenderBeginTag("div")
    writer.Write("here")
    writer.RenderEndTag()
    MyBase.Render(writer)
  End Sub
End Class


Panel doesn't work the same way as TextBox (and most controls). There is no Render method, so the override is never called. Panel uses RenderBeginTag and RenderEndTag. You may want to use the AddAttributesToRender method too.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号