asp.net - Custom LiteralControl does not insert into page -
i tired of creating system.web.ui.literalcontrol everytime need add control in webforms. so, decided me if created custom literalcontrol initialized value.
so, created simple class:
public class scriptliteralcontrol inherits system.web.ui.literalcontrol private _text string public sub new() me.initcontrol() end sub private sub initcontrol() me._text = "<script type=""text/none""></script>" end sub public overrides property text string return me._text end set(value string) me._text = value end set end property end class
but when in webpages:
dim slc new scriptliteralcontrol me.header.controls.add(slc)
absolutely nothing gets added.
according asp.net documentation i've read, had override text property in implementation doesn't seem working.
can tell me obscure .net rule not following in implementation?
you shouldn't have override text property. think that's what's causing problem. try this:
public class scriptliteralcontrol inherits system.web.ui.literalcontrol public sub new() me.text = "put script text here" end sub end class
Comments
Post a Comment