Solved

ViewState with AJAX in ASP.NET

Posted on 2009-06-30
6
649 Views
Last Modified: 2012-05-07
Hi,

I have a page with AJAX enabled. I want to store some information on server side in the ViewState object as

ViewState("Key") = Value

Does this persists between the postbacks - because page is a partial rendering ? If it is not going to be persisted between the postbacks then what i need to do to get the value from ViewState ?

Thanks
0
Comment
Question by:milani_lucie
  • 3
  • 2
6 Comments
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 240 total points
ID: 24749601
Does it need to be in the viewstate or can you store it in the session?

Session("key") = value
0
 

Author Comment

by:milani_lucie
ID: 24749641
ged325:

Needs to be in ViewState. I do not want the Session overhead on the server. BTW: Is Session is going to be persisted between the postbacks ?

Thanks
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 24749660
Session is persisted.

http://helpcentral.componentone.com/CS/forums/t/74987.aspx

Looks like the viewstate is not persisted.  How bout a cookie instead?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 24749683
http://blog.js-development.com/2009/02/howto-persist-viewstate-on-server-side.html

A temporary solution to persist the viewstate, but still you're going to have the server doing the work.
0
 
LVL 15

Expert Comment

by:NazoUK
ID: 24752389
If you're using updatepanels then the ViewState is persisted. The ViewState is passed back to the server when an ajax call is made and then passed back to the page.
In other words you can use ViewState as normal on a page with updatepanels but you should do so with caution: a large ViewState can slow the updatepanels to a crawl and make for a very frustrating user experience.
0
 
LVL 15

Accepted Solution

by:
NazoUK earned 260 total points
ID: 24752458
As an aside, the page ged325 linked to is talking about Client Callbacks which is not the same as the partial rendering achieved through ASP.NET AJAX and UpdatePanels.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now