Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 5th, 2006, 06:34 AM
Authorized User
Join Date: Apr 2006
Location: Stockholm, , Sweden.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default session updates too slow

Hi again,

I have a puzzling experience with a flag (English/Swedish) that I use for letting the user choose language of the web site. For some reason the page does refresh but the language settings aren't updated the first time the flag is clicked, but after that, it's updated every time. I guessed it had to do with EnableViewState or so, but I can't spot the error. Please help me out if you spot this silly error that's driving me crazy.

The sub for changing the session (and cookie too):

Protected Sub FlaggaImageButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles FlaggaImageButton.Click
        If FlaggaImageButton.ImageUrl = "img/unionjack.gif" Then Session("lang") = "en"
        If FlaggaImageButton.ImageUrl = "img/gulbla.gif" Then Session("lang") = "sv"
        Dim c As New System.Web.HttpCookie("langcookie", Session("lang"))
        c.Expires = Now.AddDays(10000)
    End Sub

The ImageButton itself:
<asp:ImageButton ID="FlaggaImageButton" runat="server" Style="z-index: 108; left: 830px; top: 120px; position: absolute;" />

The PageLoad's first lines:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Request.Cookies("langcookie") Is Nothing Then Session("lang") = Request.Cookies("langcookie").Value
        If Request.Cookies("langcookie") Is Nothing And Session("lang") Is Nothing Then Session("lang") = "sv"

        If Session("lang") = "sv" Then
            TaglineImage.ImageUrl = "img/tagline_sv.gif"
            HemsokLabel.Text = "<a href=""Default.aspx"">Hem/Sök</a>"
            HemsokLabel.ToolTip = "Till startsidan/Sök i katalogen"

Thanks in advance!


Coding is indeed a nine-to-five job; nine pm to five am.
Coding is indeed a nine-to-five job; nine pm to five am.
Reply With Quote
  #2 (permalink)  
Old June 5th, 2006, 12:12 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts

You are creating the cookie each time in the click event. You should check if the cookie exists in the page_load event, if it does'nt then create it. In the click event, just set the cookied, don't recreate it.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parameter Updates HelmutArnold Reporting Services 3 October 23rd, 2006 09:06 AM
Updates? GeekyMonkey BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 12 May 24th, 2006 12:11 PM
What happens if someone else updates the data jaideepc ADO.NET 2 August 11th, 2004 12:02 PM
Transactional UPDATEs djm2cmu BOOK: ASP.NET Website Programming Problem-Design-Solution 0 January 20th, 2004 11:42 AM

All times are GMT -4. The time now is 08:02 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.