473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cookie - postback

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?
Nov 19 '05 #1
6 2075
"Boonaap" wrote:
//code of linkbutton
HttpCookie cookie = Request.Cookies.Get("LANG");
cookie.Value = "NL";


Response.Cookies.Add(cookie);

Steven

- - -
Nov 19 '05 #2
err
sorry but this doesn't seem to help...

"Steven Spits" wrote:
"Boonaap" wrote:
//code of linkbutton
HttpCookie cookie = Request.Cookies.Get("LANG");
cookie.Value = "NL";


Response.Cookies.Add(cookie);

Steven

- - -

Nov 19 '05 #3
Response.Cookies("LANG") = "NL"
Response.Cookies("LANG").Expires = "January 15, 2009"
works for me!

"Boonaap" <Bo*****@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
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?

Nov 19 '05 #4
well not for me...

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

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

"Boonaap" <Bo*****@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
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?


Nov 19 '05 #5
"Boonaap" wrote:
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

- - -
Nov 19 '05 #6
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]
"Steven Spits" wrote:
"Boonaap" wrote:
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

- - -

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jon Cosby | last post by:
I'm trying to test browsers for cookies. I have my browser set to prompt me to accept cookies. As it is right now, I'm getting through whether I block the cookie or not (no redirect). I'm deleting...
4
by: darrel | last post by:
I'm having some problems getting a cookie set on a button click. Here is my function: Private Sub buttonSaveSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
0
by: Pram | last post by:
I have client-side javascript that create a cookie by calling document.cookie = "clientId=5"; Now on the "postback", after reading that cookie value I would like to reset its value by calling:...
2
by: news.microsoft.com | last post by:
I have an extremely odd cookie problem and had many programmers in the group looked at it but still with no solution. The following is the synptom: I have a user control ( for inputting user...
1
by: Ken Varn | last post by:
I have a page that uses two cookies. On postback, both cookies are updated and added back into the Page.Response.Cookies collection. For some reason, only the first cookie is actually updated...
6
by: Denise | last post by:
I have an application that sets a cookie through a class. I set it in a push button event on a postback. When the page reloads, a user control checks the value of that cookie to display name...
1
by: .NET Developer | last post by:
I'm having an issue that hopefully someone here can help me out with. First a quick explanation: I'm managing users of my site in a fairly custom way. (in other words I'm not using asp.net's...
1
by: segue | last post by:
Hi; I'm looking for the cookie in my personalfolder directory that I thought this postback code should create. Dim MyCookieCollection As New HttpCookieCollection Dim MyCookie As New...
0
by: Laura K | last post by:
I am working with a shopping cart (I am suing a book). At this point I am trying to add the cartID, the productID, quantity and time. At the same time it is supposed to add a cookie. When I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.