ViewState can be customized to be stored in a Session or Cache object. It
is done by overriding the 'SavePageStateToPersistenceMedium' and
'LoadPageStateFromPersistenceMedium' methods.
Add Following Two Override Method in to code behind file:
Step 1:
Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
If Session("ViewState") <> Nothing Then
Return (New LosFormatter().Deserialize(DirectCast(Session("ViewState"), String)))
End If
End Function
Step 2:
Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal state As Object)
Dim los As New System.Web.UI.LosFormatter()
Dim sw As New System.IO.StringWriter()
los.Serialize(sw, state)
Dim vs As String = sw.ToString()
Session("ViewState") = Nothing
Session("ViewState") = vs
End Sub
Advantage of Moving ViewState object to Session Variable :
If the ViewState size is large, it increases the page size when it load in the browser and results in an increase in response time to load page performance.
Saving the ViewState to a Session can result in an improved response time as it reduce the ViewState object to Session but it use the server resource to store session information, so need to improve hardware information.
Information about ASP.NET, C#, VB.NET,JQuery, AJAX, SQL Server, Java script,.NET tips and tricks, LINQ, OOPS Concept, DotNet Interview Questions
Showing posts with label ViewState. Show all posts
Showing posts with label ViewState. Show all posts
Friday, March 23, 2012
Subscribe to:
Posts (Atom)
ShareThis
Welcome
Welcome to Rajesh Prajapati, asp.net blog.
Here you can find some useful code and information about asp.net., c#, VB.net, SQL Server, Web Service, Web Designing etc
Here you can find some useful code and information about asp.net., c#, VB.net, SQL Server, Web Service, Web Designing etc