473,395 Members | 2,446 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,395 software developers and data experts.

session variables incrementing with a master page

Hi

VB.net 2.0 website developed with VWD 2005 Express
one masterpage
one content page aspx
and a global.asax
in the session start event of the global.asax file i declare a
session variable:
session("ItemCount") = 0
in the masterpage there is an asp:label
in the masterpage load event i put this:
label1.text = session("ItemCount").ToString()
on the content page (default.aspx) i have an imageButton. on the
onlclick event of the imagebutton i have this:
session("ItemCount") = session("ItemCount") + 1
HERES THE PROBLEM:
i press the image button, the page and masterpage reload, and the label

still says 0. BUT i press it again, everything reloads and it goes to
1. ress again and it goes to 2.
My question is, why doesnt it increment to 1 the FIRST time i press the

imagebutton?????
Thanks for your help
Ames

Oct 31 '06 #1
2 1969
Hi
>
VB.net 2.0 website developed with VWD 2005 Express

one masterpage
one content page aspx
and a global.asax

in the session start event of the global.asax file i declare a
session variable:

session("ItemCount") = 0

in the masterpage there is an asp:label

in the masterpage load event i put this:

label1.text = session("ItemCount").ToString()

on the content page (default.aspx) i have an imageButton. on the
onlclick event of the imagebutton i have this:

session("ItemCount") = session("ItemCount") + 1

HERES THE PROBLEM:

i press the image button, the page and masterpage reload, and the label

still says 0. BUT i press it again, everything reloads and it goes to
1. ress again and it goes to 2.

My question is, why doesnt it increment to 1 the FIRST time i press the

imagebutton?????

Thanks for your help

Ames
If you put breakpoints at those two places where you work with that
session variable, you see that the "load" event is executed first (so
it will display the "old" itemcount) and *then* the click event is
executed (so the itemcount is incremented).

Solution: move the "label1.Text = .." statement to the PreRender event.

Hans Kesting
Oct 31 '06 #2
YOU ARE A GENIUS!!!! THANKYOU!!!

Oct 31 '06 #3

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

Similar topics

4
by: Sam | last post by:
I have an asp.net 2.0 app that uses a sitemap, Master Page, and has several content pages. While this feature has simplified the process of creating a data-driven site menu, it does seem to have...
26
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
0
by: TheAmes | last post by:
Hi VB.net 2.0 website developed with VWD 2005 Express one masterpage one content page aspx and a global.asax
1
by: Chad | last post by:
When I visit a specific web page, Request.aspx, for some reason my session variables are cleared. I noticed that there is a "EnableSessionState" property on the document object that has three...
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: 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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...
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...

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.