Today, I'm trying to make a custom server control, requiring this control with a URL property, all the controls in this control can have the ability of the URL steering to be implemented in this sentence " Output.addattribute (htmltextwriterattribute.href, "www.163.com", but this way is some shortcomings, that is, you need to override the control, then the original properties are lost, if you use mybase.render (Output) If you do override, the picture control can't add the steering attribute, this is very confused, is it because of the cause of the layer in the middle. The result decises it with another way, it is to use the client event, which is JavaScript, and finally formed The code is as follows IMPORTS System.Web.uiImports System.drawingImports System.drawingImports System
Private _URL AS STRING = String.empty Property URL () AS STRING GET RETURN _URL END GET SET (BYVAL VALUE AS STRING) _URL = Value End Set End Property
Protected Overrides Sub Render (Byval Output As System.Web.ui.htmlTextWriter)
Output.WriteBegintag ("a") DIM FULLTEST AS STRING = "JavaScript: Window.Open ('" & _url & ");" Output.writeAttribute ("onclick", fulltest) Output.writeAttribute ("href", "# ") MyBase.Render (Output) Output.writeEndtag (" a ")
End Subend Class This kind of any control in this control has a steering attribute, and the control itself is not allowed to keep it.