Combining attributes with base class

R

Rami Cohen

Hi

I am creating a custom button control, inheriting from
System.Web.UI.WebControls.Button. I need to add client-side script to the
onclick event.
The problem is that the onclick attribute is generated by the Button base
class if validation is enabled. If I override the AddAttributesToRender
method and call base.AddAttributesToRender(), the base class renders all the
button attributes, including the onclick event with the client side
validation script. If I don't call it, I have to call writer.AddAttribute
for each and every base class attribute.
I tried adding my onclick attribute using this.Attributes.Add("onclick",
"bla();"). This is not good enough because the base class adds my code
before the validation code, and I need it to be reversed.

Any suggestions?

Thanks

Rami
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top