Cookie - postback

G

Guest

User chooses language in which he wishes to continue, this is stored in a
cookie
(so next time he comes back he doenn't have to choose his lang again)

on every page I have a user control with three linkbuttons where he can
change the lang in which he works
so the value of the cookie should be changed
but after PostBack, I still get the old value...

//Code of Main page
Page_Load(object sender, System.EventArgs e){
string vLang = fCookieLang();
//rest of code...

}

public string fCookieLang()
{
HttpCookie cookie = Request.Cookies["LANG"];
if(null == cookie){
return null;

}else{
return cookie.Value.ToString();
}
}

//code of linkbutton
HttpCookie cookie = Request.Cookies.Get("LANG");
cookie.Value = "NL";


anybody knwos what's happening?
 
J

John Blair

Response.Cookies("LANG") = "NL"
Response.Cookies("LANG").Expires = "January 15, 2009"
works for me!
 
G

Guest

well not for me...

figured out that it has something to do with PostBack or not...

John Blair said:
Response.Cookies("LANG") = "NL"
Response.Cookies("LANG").Expires = "January 15, 2009"
works for me!

Boonaap said:
User chooses language in which he wishes to continue, this is stored in a
cookie
(so next time he comes back he doenn't have to choose his lang again)

on every page I have a user control with three linkbuttons where he can
change the lang in which he works
so the value of the cookie should be changed
but after PostBack, I still get the old value...

//Code of Main page
Page_Load(object sender, System.EventArgs e){
string vLang = fCookieLang();
//rest of code...

}

public string fCookieLang()
{
HttpCookie cookie = Request.Cookies["LANG"];
if(null == cookie){
return null;

}else{
return cookie.Value.ToString();
}
}

//code of linkbutton
HttpCookie cookie = Request.Cookies.Get("LANG");
cookie.Value = "NL";


anybody knwos what's happening?
 
S

Steven Spits

Boonaap said:
err
sorry but this doesn't seem to help...

In your example, you get vLang in the Page_Load event. The LinkButton will
occur after that, so the value of vLang will remain unchanged until next
postback.

Steven

- - -
 
G

Guest

I am using this way of work to be able to display my menu-items in different
languages, so it should happen in the PageLoad event

or doesn't it ?

it used to work with Request.Params[LAngcode]
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top