开发者

asp.net custom server control design time support

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜