checkboxlist "AddAttributesToRender"

Discussion in 'ASP .Net Building Controls' started by TS, Feb 16, 2009.

  1. TS

    TS Guest

    when i override this in my custom checkboxlist, the event is never called.
    what am i doing wrong?

    I want to add some attributes to get rendered to the <table> element. I did
    do a workaround to just add these attributes in Onprerender, but thought
    correct way was to override addattributestoRender

    thanks
     
    TS, Feb 16, 2009
    #1
    1. Advertising

  2. When you did the override, did you include

    MyBase.AddAttributesToRender
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "TS" <> wrote in message
    news:%...
    > when i override this in my custom checkboxlist, the event is never called.
    > what am i doing wrong?
    >
    > I want to add some attributes to get rendered to the <table> element. I
    > did do a workaround to just add these attributes in Onprerender, but
    > thought correct way was to override addattributestoRender
    >
    > thanks
    >
    >
     
    Nathan Sokalski, Feb 17, 2009
    #2
    1. Advertising

  3. Hello TS,

    Based on my understanding, you built a custom control which inherits from
    CheckBoxList. You added some attributes and client events in
    AddAttributesToRender method. But the related attributes and events can't
    be rendered out. If I have misunderstood you, please feel free to let me
    know.
    As far as I know, this is a known issue. The issue that caused this
    oversight is in that the CheckBoxList renders both a table tag and mutiple
    input tags. It is ambiguous as to which tag should receive the attributes
    added in AddAttributesToRender method. Fixing this issue would involve a
    major design decision (potentially adding some object to allow the addition
    of attributes to inner tags) and a large amount of code, so it is not
    fixable at this point.

    Resolution:
    To work around this problem, you can add the attribute to the CheckBoxList
    via the Attributes collection in the PreRender phase. An alternative
    workaround
    would be to write an entirely new CheckBoxList control (deriving from
    ListControl) that performs the additional functionality needed.



    Sincerely,

    Vince Xu

    Microsoft Online Support

    £½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    MSDN Managed Newsgroup support offering is for non-urgent issues where an
    initial response from the community or a Microsoft Support Engineer within
    2 business day is acceptable. Please note that each follow up response may
    take approximately 2 business days as the support professional working with
    you may need further investigation to reach the most efficient resolution.
    The offering is not appropriate for situations that require urgent,
    real-time or phone-based interactions. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
     
    Vince Xu [MSFT], Feb 17, 2009
    #3
  4. TS

    TS Guest

    thanks, but actually I never got to the point where the attributes were
    added because that overriden event was never fired. I could put a breakpoint
    inside my overriden AddAttributesToRender method but it would never be hit.
    Is there a reson why this event was not called?

    "Vince Xu [MSFT]" <> wrote in message
    news:...
    > Hello TS,
    >
    > Based on my understanding, you built a custom control which inherits from
    > CheckBoxList. You added some attributes and client events in
    > AddAttributesToRender method. But the related attributes and events can't
    > be rendered out. If I have misunderstood you, please feel free to let me
    > know.
    > As far as I know, this is a known issue. The issue that caused this
    > oversight is in that the CheckBoxList renders both a table tag and mutiple
    > input tags. It is ambiguous as to which tag should receive the attributes
    > added in AddAttributesToRender method. Fixing this issue would involve a
    > major design decision (potentially adding some object to allow the
    > addition
    > of attributes to inner tags) and a large amount of code, so it is not
    > fixable at this point.
    >
    > Resolution:
    > To work around this problem, you can add the attribute to the CheckBoxList
    > via the Attributes collection in the PreRender phase. An alternative
    > workaround
    > would be to write an entirely new CheckBoxList control (deriving from
    > ListControl) that performs the additional functionality needed.
    >
    >
    >
    > Sincerely,
    >
    > Vince Xu
    >
    > Microsoft Online Support
    >
    > £½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
    >
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >
    > MSDN Managed Newsgroup support offering is for non-urgent issues where an
    > initial response from the community or a Microsoft Support Engineer within
    > 2 business day is acceptable. Please note that each follow up response may
    > take approximately 2 business days as the support professional working
    > with
    > you may need further investigation to reach the most efficient resolution.
    > The offering is not appropriate for situations that require urgent,
    > real-time or phone-based interactions. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    >
     
    TS, Feb 19, 2009
    #4
  5. TS

    TS Guest

    yes, but since that event was never fired, that line of code was never
    executed.

    "Nathan Sokalski" <> wrote in message
    news:eRYKw%...
    > When you did the override, did you include
    >
    > MyBase.AddAttributesToRender
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    > "TS" <> wrote in message
    > news:%...
    >> when i override this in my custom checkboxlist, the event is never
    >> called. what am i doing wrong?
    >>
    >> I want to add some attributes to get rendered to the <table> element. I
    >> did do a workaround to just add these attributes in Onprerender, but
    >> thought correct way was to override addattributestoRender
    >>
    >> thanks
    >>
    >>

    >
    >
     
    TS, Feb 19, 2009
    #5
  6. Hello TS,

    Sorry for my misunderstanding in my previous post. I reproduced this
    scenario and do more research about it. At last, I found some clues about
    it.

    All web controls derive from WebControl class. In WebControl, it builds
    AddAttributesToRender method and defines Render method to be inherited by
    other child classes.
    In Render method of WebControl, it will call RenderBeginTag, RenderContents
    and RenderEndTag methods.
    protected internal override void Render(HtmlTextWriter writer)
    {
    this.RenderBeginTag(writer);
    this.RenderContents(writer);
    this.RenderEndTag(writer);
    }

    In RenderBeginTag method, it will call AddAttributesToRender method which
    is defined in WebControl.
    But in CheckBoxList and RadioButtonList, render method is rewritten at all
    without touching RenderBeginTag method and AddAttributesToRender method.
    Hence, AddAttributesToRender as well as other methods which are called in
    Render method of WebCotnrol(contains RenderBeginTag , RenderContents and
    RenderEndTag methods) will not be triggered.

    For OnPreRender method, it will be fired before Render method, so it is
    still available.

    CheckBoxList will render a table with several items inside that is
    something like a composite control. By design, we needn't to define any
    attributes or styles for the entire object so that it can be like a
    collection of multiple CheckBox controls. With the table element
    participating, there are no BeginTag and EndTag needs to render. However,
    there is an additional method "RenderItem" that we can make use of to do
    something on the present item. Besides this, we can also use OnPreRender
    to add attributes on it.

    If it's inappropriate to use OnPreRender in your case, please let me know.
    I will be happily work with you on further questions.
     
    Vince Xu [MSFT], Feb 20, 2009
    #6
  7. TS

    TS Guest

    sounds good, thanks

    "Vince Xu [MSFT]" <> wrote in message
    news:...
    > Hello TS,
    >
    > Sorry for my misunderstanding in my previous post. I reproduced this
    > scenario and do more research about it. At last, I found some clues about
    > it.
    >
    > All web controls derive from WebControl class. In WebControl, it builds
    > AddAttributesToRender method and defines Render method to be inherited by
    > other child classes.
    > In Render method of WebControl, it will call RenderBeginTag,
    > RenderContents
    > and RenderEndTag methods.
    > protected internal override void Render(HtmlTextWriter writer)
    > {
    > this.RenderBeginTag(writer);
    > this.RenderContents(writer);
    > this.RenderEndTag(writer);
    > }
    >
    > In RenderBeginTag method, it will call AddAttributesToRender method which
    > is defined in WebControl.
    > But in CheckBoxList and RadioButtonList, render method is rewritten at all
    > without touching RenderBeginTag method and AddAttributesToRender method.
    > Hence, AddAttributesToRender as well as other methods which are called in
    > Render method of WebCotnrol(contains RenderBeginTag , RenderContents and
    > RenderEndTag methods) will not be triggered.
    >
    > For OnPreRender method, it will be fired before Render method, so it is
    > still available.
    >
    > CheckBoxList will render a table with several items inside that is
    > something like a composite control. By design, we needn't to define any
    > attributes or styles for the entire object so that it can be like a
    > collection of multiple CheckBox controls. With the table element
    > participating, there are no BeginTag and EndTag needs to render. However,
    > there is an additional method "RenderItem" that we can make use of to do
    > something on the present item. Besides this, we can also use OnPreRender
    > to add attributes on it.
    >
    > If it's inappropriate to use OnPreRender in your case, please let me know.
    > I will be happily work with you on further questions.
    >
     
    TS, Feb 23, 2009
    #7
    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. JD
    Replies:
    5
    Views:
    11,683
    NetArchitect
    Aug 8, 2007
  2. Henri
    Replies:
    2
    Views:
    741
    Henri
    Oct 5, 2004
  3. Patrick.O.Ige
    Replies:
    5
    Views:
    19,129
    Patrick.O.Ige
    Jun 19, 2005
  4. Henri

    Problem with LinkButton and AddAttributesToRender

    Henri, Oct 3, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    136
    Henri
    Oct 3, 2004
  5. Paul L

    Custom CheckBox class not calling AddAttributesToRender

    Paul L, Mar 17, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    134
    Paul L
    Mar 17, 2005
Loading...

Share This Page