473,320 Members | 1,993 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,320 software developers and data experts.

Weird problem :-(

Hi everyone

I am having the following very bizzare and annoying problem:

I have a page that contains amongst other things, a check box that is set
according to a session variable.

When the page loads, the check box is set according to the session variable.

Now here's the weird bit. If I change the checkbox and press the button that
I've also made, the checkbox.Checked property is still set to whatever it
was set to when the page loaded.

It's like its ignoring the fact that the checkbox was changed.

Does anyone know what could cause this?

Thanks all

Simon
Nov 18 '05 #1
3 1049
is it loaded in the page_load?
If so only have it pull from the session when IsPostBack is false

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Simon Harvey" <si**********@the-web-works.co.uk> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Hi everyone

I am having the following very bizzare and annoying problem:

I have a page that contains amongst other things, a check box that is set
according to a session variable.

When the page loads, the check box is set according to the session variable.
Now here's the weird bit. If I change the checkbox and press the button that I've also made, the checkbox.Checked property is still set to whatever it
was set to when the page loaded.

It's like its ignoring the fact that the checkbox was changed.

Does anyone know what could cause this?

Thanks all

Simon

Nov 18 '05 #2
What a dick I am. You're totally right.

Can't believe I missed that

Thanks for your help

Kindest Regards

Simon
Nov 18 '05 #3
Simon Harvey wrote:
I have a page that contains amongst other things, a check box that is set
according to a session variable.

When the page loads, the check box is set according to the session variable.

Now here's the weird bit. If I change the checkbox and press the button that
I've also made, the checkbox.Checked property is still set to whatever it
was set to when the page loaded.

It's like its ignoring the fact that the checkbox was changed.


It's likely caused because in your Page_Load event handler you're ALWAYS
setting the CheckBox' Checked property based on the Session variable
value, right? That is, you have something like:

Sub Page_Load(...)
myCB.Checked = Session("Blah")
End Sub

Instead, you should use:

Sub Page_Load(...)
If Not Page.IsPostBack then
myCB.Checked = Session("Blah")
End If
End Sub
Why? Well, the Page_Load event handler ALWAYS runs before ANY Web
control event handlers. So if you have, say, the CheckBox's
CheckChanged event wired up to some event handler, by the time that
runs, the CheckBox will have been reset back to the Session variable
value from the Page_Load event handler.

Does this make sense? I'm not 100% certain I'm directly addressing your
question... let me know if this doesn't clear things up... Thanks!
--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
Nov 18 '05 #4

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

Similar topics

2
by: Gabriel Afana | last post by:
I have a simple php script to just send email.....When I first load the script in a browser...it sends 2 emails. Why?? The weird thing is then when I refresh the page, it send only one email...I...
3
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed...
13
by: Wolfgang Kaml | last post by:
Hello All, I have been researching newsgroups and knowledgebase all morning and not found a solution that would solve the problem I have. I am having an ASP or ASPX web page that implement a...
0
by: LRW | last post by:
I manage our mySQL database through putty (SSH terminal client). And whenever I do a select * from the table that contains ENCODEd passwords, the funky characters do funky things with the display....
2
by: jwbeaty | last post by:
Here's a weird one. I'm running SQL Server 7 and when I run a backup something weird happens. When I perform the backup via Enterprise Manager by right clicking on the database I want to...
1
by: Kaneda | last post by:
Hello everyone! I have some weird(?) problems, and I am not quite sure if there are due to my errors or maybe a limitation in the .Net framework. I have a ComboBox I need to fill with the...
0
by: Kaneda | last post by:
Hello everyone! I have some weird(?) problems, and I am not quite sure if there are due to my errors or maybe a limitation in the .Net framework. I have a ComboBox I need to fill with the...
82
by: nobody | last post by:
Howdy, Mike! mikecoxlinux@yahoo.com (Mike Cox) wrote in message news:<3d6111f1.0402271647.c20aea3@posting.google.com>... > I'm a C++ programmer, and have to use lisp because I want to use >...
3
by: aling | last post by:
Execute following T-SQL within Queary Analyzer of SQL Server 2000: ======================================= DECLARE @dTest DATETIME SET @dTest='2001-1-1 1:1:1:991' SELECT @dTest SET...
0
by: P Pulkkinen | last post by:
Dear all, sorry, i know this code is far little too long to debug here, but there is really annoying logical error. If someone debugs this, I really offer warm virtual handshake. What this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.