473,769 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cookies and Events Problems

Hi Folks,

I'm just beggining with asp.net, and I'm doing a webpage to learn it. In the
main page, there is a text by default written in Portuguese, that the user
can change it it English by clicking on a button. When you click in this
button it writes a cookie with your chosen language, and then the page loads
again to change the text. However I'm having two problems, first, the cookie
doens't work, second, to fix the cookie problem, i marked each line of the
below code with a breakpoint, then I noticed that when i click in the button
the Page.Load event is raised then the Button.Click if raises after.. Why
this? Is it really supposed to happen? I'm more preocupated with the second
problem cause i'm used to windows appications and I was not expecting that
this could happen.
This is the code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim lang As String 'p means portuguese, e means english.
If Response.Cookie s("Site")("Lang ") = "english" Then
lang = "infoe.txt"
btnSwitch.Text = "Portugues"
Else
lang = "infop.txt"
btnSwitch.Text = "English"
End If
Dim ir As New IO.StreamReader (Server.MapPath ("./Data/" & lang), enc)
lblInfo.Text = ir.ReadToEnd
ir.Close()
End Sub

Private Sub btnSwitch_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSwitch.Click
Dim langc As String = Request.Cookies ("Site")("Lang" )
If langc = "portugues" Or langc = String.Empty Then
Request.Cookies ("Site")("Lang" ) = "english"
Request.Cookies ("Site").Expire s = Now.AddMonths(1 )
Else
Request.Cookies ("Site")("Lang" ) = "portugues"
Request.Cookies ("Sitet").Expir es = Now.AddMonths(1 )
End If
End Sub

Any help would be VERY apprecciated.
Thanks in advance.
ltt19
Nov 19 '05 #1
1 1065
"ltt19" <lt***@discussi ons.microsoft.c om> wrote in message
news:91******** *************** ***********@mic rosoft.com...
Hi Folks,

I'm just beggining with asp.net, and I'm doing a webpage to learn it. In
the
main page, there is a text by default written in Portuguese, that the user
can change it it English by clicking on a button. When you click in this
button it writes a cookie with your chosen language, and then the page
loads
again to change the text. However I'm having two problems, first, the
cookie
doens't work, second, to fix the cookie problem, i marked each line of the
below code with a breakpoint, then I noticed that when i click in the
button
the Page.Load event is raised then the Button.Click if raises after.. Why
this? Is it really supposed to happen? I'm more preocupated with the
second
problem cause i'm used to windows appications and I was not expecting that
this could happen.


Yes, Page_Load is meant to be raised before Click events. Take a look at
The ASP.NET Page Object Model
(http://msdn.microsoft.com/library/de...sp?frame=true).

John Saunders


Nov 19 '05 #2

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

Similar topics

4
2661
by: Phil Powell | last post by:
Ok now it has turned to the bizarre. In /cma/index.php, which sets the cookie: setcookie('username', $username, time() + 600); .... header("Location..."); It redirects to the TCL CGI /cma_main.cgi which in turns does NOT see the cookie name "username" ever set. I go to my /Phil/Cookies folder for the
0
1392
by: yukon | last post by:
Hi there the next is my platform IIS5 windows 2000 asp vbscript My working area has the next virtual directoy: testAc (corrective ambient) testAe (evolutionary ambient)
0
1639
by: Dan Meehan | last post by:
I created a music website that allows people to sign up and post messages on some message boards and update their profiles and such. The login script uses cookies, so when they Log Into the site it does something like: Response.cookies("ID") = RS.fields("UserID").value Response.cookies("USERNAME") = RS.fields("Username").value Response.cookies("LEVEL") = RS.fields("ULevel").value and from there, I have a header include that will...
2
3347
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of the user. I want that cookie should get deleted when user closes the browser without signing out. I think it is done in global.asa file . But i don;t know how to do it?
9
2537
by: | last post by:
Is it possible for a user to enable permanent cookies but disable session cookies.....this seems like a contradition yet this is what I appear to be reading in online articles?
6
3058
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a cookie (say Response.Cookies ("TEST")) and you have a query string variable &test=x or &Test=x and you get Request.QueryString to parse the query string, the cookie that gets dropped matches the case of the query string, not what your code says. ...
3
1774
by: Nicolae Fieraru | last post by:
Hi All, I have a lot of problems with the web site www.ggsurf.com.au I host on www.gnxonline.com and I want to find out if it is my own problem or theirs. I try to use session cookies and it doesn't work fine. Eventually I created some test scripts, which can be found in here: www.ggsurf.com.au/info.asp There is a link to Set the Session("TransactionID") = 25 and the page
4
1683
by: BobRoyAce | last post by:
I have a C# ASP.NET page that I inherited which has two panels on it. It only ever shows one or the other. Initially, it shows panel one. Then, if the user clicks on a certain button, it ultimately shows the other (after a postback, of course). What I need to do it put code into place that will allow code in the Page_Load event, in the case of a PAGE REFRESH (NOTE: Page involved is stored in a FRAME which is part of a FRAMESET), to know...
5
2811
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We have been looking our asses off but can not find a working solution. the code we came up with is ...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.