Dynamically switch page direction

Discussion in 'ASP .Net' started by =?Utf-8?B?bW9oZG93YWlz?=, Jun 10, 2004.

  1. 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.
    =?Utf-8?B?bW9oZG93YWlz?=, Jun 10, 2004
    #1
    1. Advertising

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

    George.


    "mohdowais" <> wrote in message
    news:...
    > 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.
    George Ter-Saakov, Jun 10, 2004
    #2
    1. Advertising

  3. On Thu, 10 Jun 2004 11:11:01 -0700, mohdowais
    <> wrote:

    >
    > <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.

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
    Craig Deelsnyder, Jun 10, 2004
    #3
  4. =?Utf-8?B?bW9oZG93YWlz?=

    bruce barker Guest

    <html id=html runat=server>

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


    -- bruce (sqlwork.com)





    "mohdowais" <> wrote in message
    news:...
    > 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.
    bruce barker, Jun 10, 2004
    #4
  5. 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" wrote:

    > <html id=html runat=server>
    >
    > html.Attributes["dir"] = Session["dir"];
    >
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    >
    >
    > "mohdowais" <> wrote in message
    > news:...
    > > 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.
    >
    >
    >
    =?Utf-8?B?bW9oZG93YWlz?=, Jun 17, 2004
    #5
    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. =?Utf-8?B?SXJmYW4gQWtyYW0=?=

    Re-direction to another aspx page

    =?Utf-8?B?SXJmYW4gQWtyYW0=?=, Feb 6, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    426
    Lionel LASKE
    Feb 7, 2005
  2. NEWS GROUPS

    How to force Page Direction

    NEWS GROUPS, Oct 5, 2005, in forum: HTML
    Replies:
    4
    Views:
    2,247
    Neredbojias
    Oct 6, 2005
  3. =?Utf-8?B?YmluZHVyYWplZXNo?=

    page direction inherits

    =?Utf-8?B?YmluZHVyYWplZXNo?=, Jul 31, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    335
    =?Utf-8?B?YmluZHVyYWplZXNo?=
    Jul 31, 2006
  4. Andy B
    Replies:
    1
    Views:
    271
    Alvin Bruney [ASP.NET MVP]
    May 29, 2008
  5. Switch Within A Switch

    , Apr 22, 2006, in forum: Javascript
    Replies:
    7
    Views:
    106
    Lasse Reichstein Nielsen
    Apr 22, 2006
Loading...

Share This Page