HighTechTalks DotNet Forums  

problem with Mobile Form CustomAttributes property in ASP.NET

ASP.net Mobile microsoft.public.dotnet.framework.aspnet.mobile


Discuss problem with Mobile Form CustomAttributes property in ASP.NET in the ASP.net Mobile forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?TmFkYXYgUG9wcGxld2VsbA==?=
 
Posts: n/a

Default problem with Mobile Form CustomAttributes property in ASP.NET - 09-03-2007 , 08:58 AM






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


Reply With Quote
  #2  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default RE: problem with Mobile Form CustomAttributes property in ASP.NET - 09-04-2007 , 01:46 AM






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


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


Regards,
Walter Wang (wawang (AT) online (DOT) 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.


Reply With Quote
  #3  
Old   
=?Utf-8?B?TmFkYXYgUG9wcGxld2VsbA==?=
 
Posts: n/a

Default RE: problem with Mobile Form CustomAttributes property in ASP.NET - 09-05-2007 , 12:38 AM



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.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.