Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mike 2 posts 22 karma points
    Jan 11, 2012 @ 20:22
    Mike
    0

    Setting macro attributes in code behind not setting value

    I have a macro within a regular asp:repeater control.

    In the ItemDataBound event handler I am attempting to set the macro's attributes that point to a custom public property that is exposed.

    macro.Attributes.Add("toutid", node.Id.ToString());

    or

    macro.MacroAttributes.Add("toutid", node.Id);

    Regular case, lower case etc.. nothing makes any difference. It loads the user control associated to the macro.. but the value of the ToutId property is never set!

    Any insight into how this might be achieved would be great.

    Thanks

  • Mike 2 posts 22 karma points
    Jan 11, 2012 @ 20:36
    Mike
    0

    Just to follow up.. I changed my ItemTemplate to have a PlaceHolder inside of it.. and then create the macro via code in the OnItemDataBound event.. then add the macro to the placeholder. It works. However I have to set the attribute using the Attributes not the MacroAttributes.

    Why can't I access the macro directly from the ItemTemplate.. why do I have to create it in code and then add it to a placeholder to have the attributes actually work?

  • Rodion Novoselov 694 posts 859 karma points
    Jan 16, 2012 @ 18:58
    Rodion Novoselov
    0

    Hi, Mike. It happens because actually macro control attributes are copied to parameters earlier than ItemDataBound happens. You can workaround it by setting the attributes you need on the ItemCreated event instead of the ItemDataBound one.

Please Sign in or register to post replies

Write your reply to:

Draft