Last post Jun 14, 2008 10:59 AM by ihsany
Jun 11, 2008 03:52 PM|shalan99|LINK
I am posting here as it has relevance to a control I am developing. I have a class that I want to inherit from LinkButton, but I also want to give a developer the option to "convert" this to a Hyperlink by providing a NavigateURL property, which will render
After much debate, I decided to rather override the render method and write out the html (writer.write([link markup])). this way I am able to control the value of href, either with a URL or with doPostBack(...), as well as some other styling that I couldn't
override any other way (rambling...when u set a height or width property of a control, the rendered output reads something like : style="height:20px; display:inline-block" which is undesirable for my purposes)
Anyway, I have subsequently decided to inherit from WebControl, and cater for the additional properties of Linkbutton/Hyperlink (yes, i know..the looong route!)
the only 3 properties I cant seem to wrap my head around and cater for are CommandArgument, CausesValidation and CommandName. I cant see any different output to the HTML in Page-source view, so how do these render? Does an additional script run?
Hope I am making sense with all of this! [:$]
Jun 14, 2008 10:59 AM|ihsany|LINK
there is not an additional script. But Hyperlink control has some attributes on render. one of them is "href" ..
but if you want to your custom Hyperlink, you can use WebControl object to serve your custom web control.
and your render class may be like below,
protected override void Render(HtmlTextWriter writer)
// Make sure this control is in a server form.
if (Page != null)
and you can use; protected
override void AddAttributesToRender(HtmlTextWriter writer)
method for customize your custom web control. In this method you can add some attributes to your control. For example;
i hope this help you..