Combining attributes with base class

Discussion in 'ASP .Net Building Controls' started by Rami Cohen, May 31, 2004.

  1. Rami Cohen

    Rami Cohen Guest

    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
     
    Rami Cohen, May 31, 2004
    #1
    1. Advertising

  2. Rami Cohen

    Natty Gur Guest

    Hi,

    Try Page.RegisterXXX to emit javascript code that use DHTML attachEvent
    to call your onclick implementation.

    HTH

    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, Jun 1, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alf P. Steinbach
    Replies:
    6
    Views:
    550
    John Carson
    Sep 3, 2005
  2. james_027

    class attributes & data attributes

    james_027, Jun 20, 2007, in forum: Python
    Replies:
    2
    Views:
    377
    Bruno Desthuilliers
    Jun 20, 2007
  3. Mike N.
    Replies:
    3
    Views:
    573
    Joseph Kesselman
    Mar 17, 2008
  4. Hicham Mouline
    Replies:
    1
    Views:
    596
    Victor Bazarov
    Apr 20, 2009
  5. Karan Rajput
    Replies:
    2
    Views:
    146
    Abinoam Jr.
    Dec 22, 2010
Loading...

Share This Page