473,545 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ 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 2088
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 oversimplificat ion 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.comw rote in message
news:10******** *************** ***********@mic rosoft.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 oversimplificat ion 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.comw rote in message
news:10******** *************** ***********@mic rosoft.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
5462
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 dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last...
4
1424
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 button in it (a simple link button) it will go to the event procedure, call the proper method and then when I try to access a field in the web control it...
1
11545
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 http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all...
10
4484
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 (basically have the data binding done in the If NOT IsPostBack Then statement). How come? How does this information get preserved? Which raises...
3
2549
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 consituent control caused a postback. for example a have a consituent controls with two buttons on it "button1" and "button2" I have registered...
4
3385
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 RaiseCallbackEvent(string eventArgs) { // update the data object with the values currently on screen FormView1.UpdateItem(true); }
4
4080
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 initially configured during DataBind(). Thanks to Steven Cheng for pointing out that you have to set the constituent control properties after you add...
1
2994
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 list items. When I don't create the control dynamically, I get a viewstate that is roughly 1 mb in size! However, when i use the code below the...
8
6890
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" key how can I set the focus to the next box after the postback? Please help! Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
0
7409
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
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...
1
7437
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...
0
7771
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5982
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...
1
5343
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...
0
4958
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...
1
1900
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
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.