Changing HTML in the Render() method

B

Benton

Hi there,

I am looking for C# code samples on how to:

1.- Get a string with the default HTML that would be rendered for a custom
control.
2.- Customize this string.
3.- Make the control render the customized HTML.

I want to customize the "HREF" part of the HTML generated for a LinkButton.
I am new to custom control writing and if this is possible it would be done
in the Render method, right?

Many thanks in advance,

-Benton
 
W

Wilco Bauwer

You could either use filters to modify the output (which is very
"low-level"), or you could override the implementation of a
LinkButton's control, which I would probably recommend. I say probably,
because I do not know exactly what you want to achieve. What should the
resulting href be?
 
B

Benton

You could either use filters to modify the output (which is very
"low-level"), or you could override the implementation of a
LinkButton's control, which I would probably recommend. I say probably,
because I do not know exactly what you want to achieve. What should the
resulting href be?

I am working on a custom control inherited from the LinkButton class. A
snippet of the default HTML output for the control looks like this:

<a href="javascript:__doPostBack('ctl00$cphHolder$lnkAgregar','')">

I want to add additional content and make it look like this:

<a href="javascript:__doPostBack('ctl00$cphHolder$lnkAgregar','')
onMouseover="window.status='Hi there!'; return true"
onMouseout="window.status=' '; return true;">

Thanks for any ideas,

-Benton
 
W

Wilco Bauwer

Why not do something like:
<asp:LinkButton ... onmouseover="window.status=...." />

Or programmatically:
myLinkButton.Attributes["onmouseover"] = "window.status....";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,087
Members
48,773
Latest member
Kaybee

Latest Threads

Top