473,471 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Page refresh question

I've got a "Select Language" drop-down on the top-right of the home page.

When I select a new language, the drop-down fires a postback and sets a
cookie and session value for "LanguageSelection". E.g. = "fr-FR"

However after this I still need to press F5 to refresh the webpage before
code in the page uses the new session variable value to display the
different language. Any ideas how to fix this?
Partial Class pages_master_page_MasterPage
Inherits System.Web.UI.MasterPage

Function fSetLanguage() As Boolean

'Check if session language exists
'If not, get cookie, if none, get browser language
'and set cookie and session language

If IsPostBack = False Then
If Session("strLanguageSetting") = Nothing Then
'Get cookie
If Response.Cookies("SiteLanguage").Value = "" Then
Response.Cookies("SiteLanguage").Value =
fGetBrowserLanguage()
End If
Session("strLanguageSetting") =
Response.Cookies("SiteLanguage").Value
End If
DropDownList1.SelectedValue = Session("strLanguageSetting")
End If

End Function

Function fLanguageChange() As Boolean

Session("strLanguageSetting") = DropDownList1.SelectedValue
Response.Cookies("SiteLanguage").Value =
Session("strLanguageSetting")
Response.Cookies("SiteLanguage").Expires =
DateTime.Now.AddDays(1000)

End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
fSetLanguage()
fSetLanguageValues()
End Sub

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
fLanguageChange()
End Sub

Function fGetBrowserLanguage() As String

Dim objUserInfo() As String
Dim strBrowserLanguage As String
Dim strWhere As String

objUserInfo = Request.UserLanguages
strBrowserLanguage = objUserInfo(0)

'If an active language then set
strWhere = "LanguageCode='" + strBrowserLanguage + "'"
If SharedFunctions.fGetSingleValueFromTable("Active",
"tblLanguageCodes", strWhere) = True Then
fGetBrowserLanguage = strBrowserLanguage
Exit Function
End If

'If not, regress to root active language, e.g. fr-CA would be fr-FR
strWhere = "LanguageCodeGeneric='" + Left(strBrowserLanguage,
InStr(strBrowserLanguage, "-") - 1) + "' AND [Active]= 'True'"
Dim strFoundLanguageCode As String
strFoundLanguageCode =
SharedFunctions.fGetSingleValueFromTable("Language Code", "tblLanguageCodes",
strWhere)
If strFoundLanguageCode <"" Then
fGetBrowserLanguage = strFoundLanguageCode
Exit Function
End If

'If not active, regress to en-US
fGetBrowserLanguage = "en-US"

End Function

Function fSetLanguageValues() As Boolean

Label1.Text = sfLanguage.fText(30)
Label2.Text = sfLanguage.fText(31)
Label3.Text = sfLanguage.fText(32)
HyperLink1.Text = sfLanguage.fText(33)

End Function

End Class

Aug 26 '08 #1
2 1009
Mark B wrote:
I've got a "Select Language" drop-down on the top-right of the home page.

When I select a new language, the drop-down fires a postback and sets a
cookie and session value for "LanguageSelection". E.g. = "fr-FR"

However after this I still need to press F5 to refresh the webpage
before code in the page uses the new session variable value to display
the different language. Any ideas how to fix this?
Can you just do a Response.Redirect after setting the cookie back to the
same page?

---
Leon Mayne
http://leon.mvps.org
Aug 26 '08 #2
Thanks!

That worked:
Function fLanguageChange() As Boolean

Session("strLanguageSetting") = DropDownList1.SelectedValue
Response.Cookies("SiteLanguage").Value =
Session("strLanguageSetting")
Response.Cookies("SiteLanguage").Expires =
DateTime.Now.AddDays(1000)
Response.Redirect(Request.Url.ToString)

End Function



"Leon Mayne" <le********@mvps.orgwrote in message
news:O4**************@TK2MSFTNGP05.phx.gbl...
Mark B wrote:
>I've got a "Select Language" drop-down on the top-right of the home page.

When I select a new language, the drop-down fires a postback and sets a
cookie and session value for "LanguageSelection". E.g. = "fr-FR"

However after this I still need to press F5 to refresh the webpage before
code in the page uses the new session variable value to display the
different language. Any ideas how to fix this?

Can you just do a Response.Redirect after setting the cookie back to the
same page?

---
Leon Mayne
http://leon.mvps.org
Aug 26 '08 #3

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

Similar topics

5
by: Bill Cohagan | last post by:
I'm constructing an ASP app with a frameset on the home html page. From frame A I need to referesh the page in frame B when a button click occurs on a button in Frame A (server side event handler)....
5
by: Dan | last post by:
We have a simple site. It's a frameset with two frames a left and a right. The left frame is essentially a list of records from a database (using a server-side repeater control). When you click...
18
by: Alan Z. Scharf | last post by:
1. I have a chain of six asynch callbacks initiated by a button, and want the page to refresh at the end of each callback to display A. Results of a SQLServer query showing cumulative running...
8
by: Judy Ward | last post by:
I have an index.aspx with frames. The top frame has a navigation bar with a "Login" hyperlink. If the user has already logged in I want this link to change to "Logout". I am using forms-based...
10
by: Fred Nelson | last post by:
Hi: I have a VB.NET web application and I need to find a way to cause a page refresh from within my application. Does anyone know how to force the browser to refresh the current page? ...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.