[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

problem with Mobile Form CustomAttributes property in ASP.NET

Nadav Popplewell

9/3/2007 1:58:00 PM

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

2 Answers

wawang

9/4/2007 6:46:00 AM

0

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/MakingTheASPNETMobileControlsRenderR...
s.aspx


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


Regards,
Walter Wang (wawang@online.microsoft.com, 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.

Nadav Popplewell

9/5/2007 5:38:00 AM

0

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.