problem with Mobile Form CustomAttributes property in ASP.NET

  • Thread starter Nadav Popplewell
  • Start date
N

Nadav Popplewell

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
 
W

Walter Wang [MSFT]

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 ([email protected], 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.
 
N

Nadav Popplewell

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.
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top