473,461 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Postback erases web control text

Hi all.

I'm having a problem with a postback issue and I think it's cache related.
Here's my setup:

I have a web site that has a signup section. This has simple things like
name, age, birth date, etc. When the user visits this page for the first
time, a person's data object that is used to store the user's name, age,
birth date, etc. is created and stored in session. On the first visit to this
page, the object is empty. Whenever the user posts back to this page, any
text from the text boxes is stored into the person's data object and the
session variable is updated.

There is a drop down control which causes the page to automatically post
back to itself and that's the year of birth drop down list. If the user
selects any year between 1993 and 2007, the page posts back to itself and a
new text box control appears for the email address of the person's parent (we
have to monitor minors 14 and under).

My problem is that sometimes when the year of birth drop down list is
changed, all the text in the other text boxes is erased. I've gone through
the code a lot and I think this is a caching issue. I can't find anything
wrong with how the code works and I don't see any way that the code is
erasing the session variable. This leaves me to believe this is a caching
issue. Does anyone know how to check caching settings in the web.config file,
app.config file, or anywhere else?
Nov 26 '07 #1
2 2084
JP:

If IIS was reset in the middle of the session, you might have something like
this. Have you happened to check your app pools and see what the recycle
settings are set to? If not, that might be a place to look. Assuming that's
not the issue and that your session isn't timing out, I'd look to the code.
Most problems with IIS would result in null values being inserted not empty
strings. If you haven't done so, look under the App Pools node in IIS Admin
and verify your settings there.

Specifically, are you wrapping each attempt to get/set the Session variables
in properties? If so, what are you doing if you detect a null session
variable? Are you setting the value to an empty string? If not, it's a
good idea to do so as opposed to accesing them directly, for the same
reasons you shouldn't touch private member variables from outside of the
class ( a bit of an oversimplification here but valid in most cases). You
can put a logging statement in the Set Accessors and then run the app and
see what happens. If you can do it predictably by a sequence of actions,
I'm inclined to think it's the code somewhere. You could add a Debug
Assertion in the set accessor as well and verify you're not setting the
value to string.empty.

It probably sounds like I'm blowing off the issue of caching or something
with IIS - it's just that in my personal experience, behavior like this is
almost always b/c I did something and didn't realize it. Either i've
overlooked something on the PostBack code or I have an If i'm overlooking or
early on in development, my exception handling is doing something funky b/c
I haven't really implemented it as well as I should have. If you are
accessing the Session variables outside of properties, then you're in a
situation where you effectively have global variables and all the problems
that come with them and that makes it really hard to isolate. if you have
properties wrapping them, then you can stick a logger statement in there,
run through the steps that cause the problem and see what is happening and
when. Another similar approach is to create a BasePage that contains the
session variables that you use from one page to another. You can have a
global base page and then inherit from it for each group of pages that uses
the same values if you want that level of granularity. Or you can just use
one. But by creating properties in a base page, you can centralize your
null checks and validation for the get/set operations and 'know' that
nothing else is changing it. In this case, b/c you have a data object,
doing this might be too much rework so you could just modify your data
object if you're not doing it already. I only keep harping on this b/c in
most cases where you have session weirdness, you usually end up with nulls.

Also, are you specfically caching anything? I guess I should have asked
this first but are you using the ASP.NET caching mechanism explicitly? If
so, have you checked how frequently it's being invalidated? To that end,
are you using cookies and possibly overwriting the values? Similarly, are
you using ViewState? Is it enabled for the controls?
"JP" <JP@discussions.microsoft.comwrote in message
news:10**********************************@microsof t.com...
Hi all.

I'm having a problem with a postback issue and I think it's cache related.
Here's my setup:

I have a web site that has a signup section. This has simple things like
name, age, birth date, etc. When the user visits this page for the first
time, a person's data object that is used to store the user's name, age,
birth date, etc. is created and stored in session. On the first visit to
this
page, the object is empty. Whenever the user posts back to this page, any
text from the text boxes is stored into the person's data object and the
session variable is updated.

There is a drop down control which causes the page to automatically post
back to itself and that's the year of birth drop down list. If the user
selects any year between 1993 and 2007, the page posts back to itself and
a
new text box control appears for the email address of the person's parent
(we
have to monitor minors 14 and under).

My problem is that sometimes when the year of birth drop down list is
changed, all the text in the other text boxes is erased. I've gone through
the code a lot and I think this is a caching issue. I can't find anything
wrong with how the code works and I don't see any way that the code is
erasing the session variable. This leaves me to believe this is a caching
issue. Does anyone know how to check caching settings in the web.config
file,
app.config file, or anywhere else?

Nov 26 '07 #2
I'm using Windows XP and my version of IIS is 5.1. I don't think the app pool
feature is something that is available in 5.1. I checked the web for some
help on it, and I believe version 6 supports this feature.

I did a thorough debugging of my code and there is no code that overwrites
my values in the session object. I checked every possible conditional branch,
every single inherited page that messed with execution, master pages and
still nothing.

I'm not using cookies. This login process is stored entorely in the session.

As far as caching is concerned, I haven't specified anything to specifically
cache data or clear the cache.

My session variables are being validated by "if session["variable"] exists,
do something" so I'm not ever getting null reference exceptions.

When I do my debugging, I go from page 1 to page 2 and the session is
totally cleared. It's really baffling.
"W.G. Ryan" wrote:
JP:

If IIS was reset in the middle of the session, you might have something like
this. Have you happened to check your app pools and see what the recycle
settings are set to? If not, that might be a place to look. Assuming that's
not the issue and that your session isn't timing out, I'd look to the code.
Most problems with IIS would result in null values being inserted not empty
strings. If you haven't done so, look under the App Pools node in IIS Admin
and verify your settings there.

Specifically, are you wrapping each attempt to get/set the Session variables
in properties? If so, what are you doing if you detect a null session
variable? Are you setting the value to an empty string? If not, it's a
good idea to do so as opposed to accesing them directly, for the same
reasons you shouldn't touch private member variables from outside of the
class ( a bit of an oversimplification here but valid in most cases). You
can put a logging statement in the Set Accessors and then run the app and
see what happens. If you can do it predictably by a sequence of actions,
I'm inclined to think it's the code somewhere. You could add a Debug
Assertion in the set accessor as well and verify you're not setting the
value to string.empty.

It probably sounds like I'm blowing off the issue of caching or something
with IIS - it's just that in my personal experience, behavior like this is
almost always b/c I did something and didn't realize it. Either i've
overlooked something on the PostBack code or I have an If i'm overlooking or
early on in development, my exception handling is doing something funky b/c
I haven't really implemented it as well as I should have. If you are
accessing the Session variables outside of properties, then you're in a
situation where you effectively have global variables and all the problems
that come with them and that makes it really hard to isolate. if you have
properties wrapping them, then you can stick a logger statement in there,
run through the steps that cause the problem and see what is happening and
when. Another similar approach is to create a BasePage that contains the
session variables that you use from one page to another. You can have a
global base page and then inherit from it for each group of pages that uses
the same values if you want that level of granularity. Or you can just use
one. But by creating properties in a base page, you can centralize your
null checks and validation for the get/set operations and 'know' that
nothing else is changing it. In this case, b/c you have a data object,
doing this might be too much rework so you could just modify your data
object if you're not doing it already. I only keep harping on this b/c in
most cases where you have session weirdness, you usually end up with nulls.

Also, are you specfically caching anything? I guess I should have asked
this first but are you using the ASP.NET caching mechanism explicitly? If
so, have you checked how frequently it's being invalidated? To that end,
are you using cookies and possibly overwriting the values? Similarly, are
you using ViewState? Is it enabled for the controls?
"JP" <JP@discussions.microsoft.comwrote in message
news:10**********************************@microsof t.com...
Hi all.

I'm having a problem with a postback issue and I think it's cache related.
Here's my setup:

I have a web site that has a signup section. This has simple things like
name, age, birth date, etc. When the user visits this page for the first
time, a person's data object that is used to store the user's name, age,
birth date, etc. is created and stored in session. On the first visit to
this
page, the object is empty. Whenever the user posts back to this page, any
text from the text boxes is stored into the person's data object and the
session variable is updated.

There is a drop down control which causes the page to automatically post
back to itself and that's the year of birth drop down list. If the user
selects any year between 1993 and 2007, the page posts back to itself and
a
new text box control appears for the email address of the person's parent
(we
have to monitor minors 14 and under).

My problem is that sometimes when the year of birth drop down list is
changed, all the text in the other text boxes is erased. I've gone through
the code a lot and I think this is a caching issue. I can't find anything
wrong with how the code works and I don't see any way that the code is
erasing the session variable. This leaves me to believe this is a caching
issue. Does anyone know how to check caching settings in the web.config
file,
app.config file, or anywhere else?


Nov 28 '07 #3

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

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
4
by: CJ Taylor | last post by:
Hey all, I have a ASP.NET application running on Rainbow Portal, (the forums ahve been kinda useless). Anyways, I have a single control that for some reason whenever I hit the calculate...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
10
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back...
3
by: Martin | last post by:
Hi, I have created a composite control that has a number of standard asp.net controls on it that can themselves cause postbacks. What i need to do in my composite control is to determine which...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
4
by: Mark Olbert | last post by:
This involves a family of related, databound ASPNET2 composite controls. I've managed to arrange things so that the composite controls restore themselves from ViewState on postback after they're...
1
by: RSH | last post by:
Hi, I am experimenting with the Viewstate and based on a few articles I have read, I put together a test. it is a simple test where I am dynamically creating a DropDownList that contains 25000...
8
by: Mel | last post by:
I have several text boxes and drop-down lists in an AJAX Update Panel. All user inputs have the Postback property set to True. After I type something in the first input entry and press the "Tab"...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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
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...
1
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...
0
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: 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...

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.