Dynamically switch page direction

G

Guest

Hi

I am fairly new to ASP.NET and I am trying to migrate an existing ASP 3.0 application to asp.Net, and I seem to have hit a roadblock (maybe I just need more coffee). The current application is bi-lingual - it supports both English and Arabic. For users who prefer Arabic, the page switches to right-to-left, we do that by simply adding a "dir='rtl'" attribute to the HTML tag. This is of course dynamically like so:

<HTML dir="<%=Session("dir")%>
....
</HTML>

How can I replicate the same functionality in ASP.NET without going into aspcompat mode? I thought it would be really easy, but I tried looking all over and I couldn't believe the Page Object does not have a RightToLeft property, or a way to edit the HTML tag generated! Surely there is an easy way to do this? Any suggestions would be welcome.
 
G

George Ter-Saakov

I guess you should do exactly the same.
<HTML dir="<%=Session["dir"]%>
Notice square brackets instead of round ones.

George.


mohdowais said:
Hi

I am fairly new to ASP.NET and I am trying to migrate an existing ASP 3.0
application to asp.Net, and I seem to have hit a roadblock (maybe I just
need more coffee). The current application is bi-lingual - it supports both
English and Arabic. For users who prefer Arabic, the page switches to
right-to-left, we do that by simply adding a "dir='rtl'" attribute to the
HTML tag. This is of course dynamically like so:
<HTML dir="<%=Session("dir")%>
...
</HTML>

How can I replicate the same functionality in ASP.NET without going into
aspcompat mode? I thought it would be really easy, but I tried looking all
over and I couldn't believe the Page Object does not have a RightToLeft
property, or a way to edit the HTML tag generated! Surely there is an easy
way to do this? Any suggestions would be welcome.
 
C

Craig Deelsnyder

<HTML dir="<%=Session("dir")%>
...
</HTML>

How can I replicate the same functionality in ASP.NET without going into
aspcompat mode? I thought it would be really easy, but I tried looking
all over and I couldn't believe the Page Object does not have a
RightToLeft property, or a way to edit the HTML tag generated! Surely
there is an easy way to do this? Any suggestions would be welcome.

If you're looking to do this conversion quickly, you can do what you were
doing there. That notation still works in ASP.NET and I don't think you
need to do aspcompat (otherwise remove the = sign and use
Response.Write("dir")

the only problem is if you're using C#, C# uses brackets for accessing
items indexed in a collection...it'd be

<HTML dir="<%=Session["dir"]%>

you could also do this in the code-behind, let me know if that's your
approach and I can show you how to do that as well (note this is the
slightly better approach as a purist, but either way will work).

Note the attribute on an HTML tag does not necessarily translate to
properties in Page class in code. You can define your own attributes in
the HTML to go into the outgoing HTML; as long as it's valid HTML of
course, it'll work correctly.
 
B

bruce barker

<html id=html runat=server>

html.Attributes["dir"] = Session["dir"];


-- bruce (sqlwork.com)





mohdowais said:
Hi

I am fairly new to ASP.NET and I am trying to migrate an existing ASP 3.0
application to asp.Net, and I seem to have hit a roadblock (maybe I just
need more coffee). The current application is bi-lingual - it supports both
English and Arabic. For users who prefer Arabic, the page switches to
right-to-left, we do that by simply adding a "dir='rtl'" attribute to the
HTML tag. This is of course dynamically like so:
<HTML dir="<%=Session("dir")%>
...
</HTML>

How can I replicate the same functionality in ASP.NET without going into
aspcompat mode? I thought it would be really easy, but I tried looking all
over and I couldn't believe the Page Object does not have a RightToLeft
property, or a way to edit the HTML tag generated! Surely there is an easy
way to do this? Any suggestions would be welcome.
 
G

Guest

George, Craig, Bruce ... you guys are tops! Thanks a lot, especially Bruce. Craig, is this what you had in mind? Or is there another way?

Cheers mates!

MO

bruce barker said:
<html id=html runat=server>

html.Attributes["dir"] = Session["dir"];


-- bruce (sqlwork.com)





mohdowais said:
Hi

I am fairly new to ASP.NET and I am trying to migrate an existing ASP 3.0
application to asp.Net, and I seem to have hit a roadblock (maybe I just
need more coffee). The current application is bi-lingual - it supports both
English and Arabic. For users who prefer Arabic, the page switches to
right-to-left, we do that by simply adding a "dir='rtl'" attribute to the
HTML tag. This is of course dynamically like so:
<HTML dir="<%=Session("dir")%>
...
</HTML>

How can I replicate the same functionality in ASP.NET without going into
aspcompat mode? I thought it would be really easy, but I tried looking all
over and I couldn't believe the Page Object does not have a RightToLeft
property, or a way to edit the HTML tag generated! Surely there is an easy
way to do this? Any suggestions would be welcome.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top