problem with Mobile Form CustomAttributes property in ASP.NET

Discussion in 'ASP .Net Mobile' started by Nadav Popplewell, Sep 3, 2007.

  1. Hi there
    I'm trying to use the Mobile Form CustomerAttributes dictionary to add some
    custom attributes to the <body> tag generated (for Html devices).
    I've set allowCustomAttributes="true" in the <mobileControls > tag in
    web.config.

    Then in the page code I've got code like this:
    if (this.AllowCustomAttributes)
    {
    if (RTL)
    {
    this.ActiveForm.CustomAttributes.Add("dir", "RTL");
    }
    }

    The 'dir' attribute IS added to the CustomAttributes dictionary.

    But the 'dir' attribute does NOT appear in the generate HTML.

    I've overriden the HtmlFormAdapter class and put a break point in the
    RenderBodyTag() method.

    When I inspect the attributes parameter passed to the RenderBodyTag() method
    I see it is empty.
    However, when I inspect the Page ActiveForm.CustomAttributes I see that it
    has the 'dir' attribute I added.

    It seems like the HtmlFormAdapter.RenderBodyTag() attributes parameter is
    NOT populated from the ActiveForm.CustomAttributes dictionary (or that the
    framework does not add the 'dir' attribute).

    If I add the 'dir' attribute to the attributes dictionary in the
    RenderBodyTag() method before calling base.RenderBodyTag() then the attribute
    is added to the generated HTML.
    However, The code that determines if this attribute need to be added is part
    of the page class and I would prefer not to have to override the FormAdapter
    and move this logic to it.

    Am I doing something wrong here?
    Does the RenderBodyTag() property get it's attribute parameter not from
    ActiveForm.CustomAttributes but from some place else?

    Thanks in advance
    Nadav
    Nadav Popplewell, Sep 3, 2007
    #1
    1. Advertising

  2. Hi Nadav,

    To render the custom attribute to output, adding the attribute itself is
    not enough, you will also need to create a custom adapter to render it.
    Here's a complete example:


    #Scott Hanselman's Computer Zen - Making the ASP.NET Mobile Controls render
    RTL languages
    http://www.hanselman.com/blog/MakingTheASPNETMobileControlsRenderRTLLanguage
    s.aspx


    Please feel free to let me know if there's anything I can help. Thanks.


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Sep 4, 2007
    #2
    1. Advertising

  3. Hi Walter,
    Thanks for your reply.

    I remembered that Scott Hanselman wrote something about this, I just
    couldn't find it.
    If I need to, I'll create a custom adapter.

    It's just a pity that we need to go to all this hassle to support basic Bidi.

    Anyway, thanks

    Nadav.
    Nadav Popplewell, Sep 5, 2007
    #3
    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. chen selina
    Replies:
    0
    Views:
    1,300
    chen selina
    Jul 13, 2010
  2. Ryan Malone
    Replies:
    0
    Views:
    165
    Ryan Malone
    Aug 23, 2004
  3. Yaiz
    Replies:
    0
    Views:
    183
  4. dave
    Replies:
    0
    Views:
    106
  5. dawson
    Replies:
    0
    Views:
    163
    dawson
    Jul 12, 2005
Loading...

Share This Page