473,320 Members | 1,863 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.

Page level variables reset during Ajax post back

Hello,

I have a aspx page with ajax scriptmanger update panel etc. I also
have public string variables on the aspx page.

Whenever postback happens from Ajax update panel, at server side all
the public string variables are reset to empty string. As if fresh
page is loaded. How to preserve the page level variables during Ajax
postback?

thanks!
Radix

Jul 23 '07 #1
3 7812
a 'fresh page' is being loaded - updatepanel postback is still a postback.
any data you wish to preserve between postbacks should be saved either in
the form ( hidden fields / view state ) or saved on the server ( session /
.... )
"radix" <ra*******@gmail.comwrote in message
news:11*********************@k79g2000hse.googlegro ups.com...
Hello,

I have a aspx page with ajax scriptmanger update panel etc. I also
have public string variables on the aspx page.

Whenever postback happens from Ajax update panel, at server side all
the public string variables are reset to empty string. As if fresh
page is loaded. How to preserve the page level variables during Ajax
postback?

thanks!
Radix

Jul 23 '07 #2
radix wrote:
Hello,

I have a aspx page with ajax scriptmanger update panel etc. I also
have public string variables on the aspx page.

Whenever postback happens from Ajax update panel, at server side all
the public string variables are reset to empty string.
They are set to null, unless you actually assign them empty strings.
As if fresh page is loaded.
That's because a fresh page _is_ loaded.

An ajax call makes a regular postback, it just doesn't make a regular
response.
How to preserve the page level variables during Ajax
postback?
You can't. You persist data between postbacks just as you do between any
other postback.

--
Göran Andersson
_____
http://www.guffa.com
Jul 23 '07 #3
Yeah, I used sessions and saved my variables.

Strings were intialized to so they were not null... but they are nulls
if not initialzed. Thanks!

On Jul 23, 4:24 pm, Göran Andersson <gu...@guffa.comwrote:
radix wrote:
Hello,
I have a aspx page with ajax scriptmanger update panel etc. I also
have public string variables on the aspx page.
Whenever postback happens from Ajax update panel, at server side all
the public string variables are reset to empty string.

They are set to null, unless you actually assign them empty strings.
As if fresh page is loaded.

That's because a fresh page _is_ loaded.

An ajax call makes a regular postback, it just doesn't make a regular
response.
How to preserve the page level variables during Ajax
postback?

You can't. You persist data between postbacks just as you do between any
other postback.

--
Göran Andersson
_____http://www.guffa.com

Jul 23 '07 #4

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

Similar topics

17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
3
by: Arun K | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
8
by: hb | last post by:
Hi, I need to declare a variable who's value can be preserve through the same ASP.Net page. I tried the following code, only the static variable s2 keeps its value=22 after lnk1_Click followed...
7
by: UJ | last post by:
I've got a page with a user control on it. While the page is loading, it needs to check certain conditions of the user object to enable/disable things on the screen. Currently in the page_load of...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
2
by: pbd22 | last post by:
can somebody tell me how to set a parameter of my current URL without using response.redirect? I am trying to set a parameter - ResponseId = 4 inside a while loop. is this possible? also,...
7
by: Schmidty | last post by:
Okay...I have another 'newbie' question; I have a function that loads a page and the action is $_SERVER; In the form that is in a function(method?) within a class a variable is passed back to...
14
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.