Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System
Public Class WebCustomControl1 : Inherits System.Web.UI.Control
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.AddAttribute(HtmlTextWriterAttribute.Href, "http://www.163.com")
output.AddAttribute(HtmlTextWriterAttribute.Target, "_blank")
output.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "100")
output.AddStyleAttribute(HtmlTextWriterStyle.Color, "Green")
output.RenderBeginTag(HtmlTextWriterTag.A)
output.Write("this is a link")
output.RenderEndTag()
End Sub
End Class
博客展示了一段代码,通过导入多个System相关命名空间,创建了一个名为WebCustomControl1的自定义控件类,该类继承自System.Web.UI.Control。在Render方法中,使用HtmlTextWriter进行输出设置,添加链接、样式等属性并输出文本。





