Click here to Skip to main content
15,888,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to access my session value in .aspx page, I try with so many method but still it doesn't show value.

C#
if (DropDownList2.SelectedItem.Text == "Arabic")
            Session["dir"] = "rtl";
        else
            Session["dir"] = "ltr";

I do like this but can't access session value :
HTML
<html xmlns="http://www.w3.org/1999/xhtml" dir='<%# Session["dir"].ToString() %>'  runat="server">


Any auggestion really appreciate
Posted
Updated 4-Dec-13 0:01am
v4

Hi

Try this..

XML
<html id="htmlid" dir="<%# Session["dir"].ToString() %>" runat="server" xmlns="http://www.w3.org/1999/xhtml"></html>




C#
// You can try in two ways..
//1) using the attributes as
//htmlid.Attributes.Add("dir", "rtl");
//2)
Session["dir"] = "rtl";
// you have to call this method (.DataBind()) of html control after you have set the value in session
htmlid.DataBind();
 
Share this answer
 
Accessing Session value Using Java Script

XML
<script type="text/javascript">
    function GetUserName()
    {

        var username = '<%= Session["UserName"] %>';
        alert(username );
    }
</script>
 
Share this answer
 
You can use a main div where I have test it in this format
And it's working !!!!!!!!!!!

XML
<p dir="rtl">Write this text right-to-left!</p>
       <div dir="<%=  Session["dir"] %>">
           Hello friends
       </div>


rtl=Right-to-left text direction
Syntax:
<p element dir="ltr|rtl|auto">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900