thanks,
Shanon
Sub Button1_Click(sender As Object, e As EventArgs)
Dim Language as string ="NL"
Session("Lang") = language
label1.text = "You have set session to Dutch"
label2.text = (language = Session("Lang"))
End Sub
Sub Button2_Click(sender As Object, e As EventArgs)
Dim Language as String = "EN"
Session("Lang") = language
label1.text = "You have set session to English"
label2.text = (language = Session("Lang"))
End SubWhen you add something to the Session, it gets boxed as an object and then stored. When you try to retrieve it, it comes back as an object. You have to unbox it by casting it to the appropriate type. I'm not too familiar with VB.NET, but in C# it'd look like this:
string language = "EN";
Session["Lang"] = language;
label1.Text = Session["Lang"].ToString(); //using a method to do the conversion
label2.Text = (string)Session["Lang"]; //a straight cast
I now get a true and false value returned but each time i run this header it will only fire the Else "false" statement. Why isn't it picking up on the "true" statement when its clearly set to true?
Public Sub Page_Load(Sender As Object, E As EventArgs)
Dim dsMenu As New DataSet()Dim language as string
language = session("lang")
if language = "true" then
dsMenu.ReadXml(server.MapPath("menu-nl.xml"))
Else language = "false"
dsMenu.ReadXml(server.MapPath("menu-uk.xml"))
End IF
Menubar.DataSource = dsMenu
Menubar.DataBind()End Sub
0 comments:
Post a Comment