Prevent "The View State is invalid for this page and might be corrupted" Error
When we use server.transfer method to navigate to next page, at times we give value; as the second parameter for the method. In this cases we tend to get the error messageThe View State
March 3, 2004
When we use server.transfer method to navigate to next page, at times we give value; as the second parameter for the method. In this cases we tend to get the error message
The View State is invalid for this page and might be corrupted .“
This is because the view state of the page where Server.Transfer is called isn't valid on the destination page.
To avoid this problem do not pass “True” as the second parameter for the Server.Transfer method. An easy and safer way to make the values of the source page available to the destination page, is to wrap these control's values in properties:
Public Class WebForm1
Private WithEvents txtloginID As System.Web.UI.WebControls.TextBox
' ...
ReadOnly Property LoginID() As String
Get
Return Me.txtloginID.Text
End Get
End Property
End Class
Inside the destination page you can access the values of the source page as
Dim source As WebPage1 = DirectCast(Context.Handler, WebForm1)
Dim loginID As String = source.loginID.
About the Author
You May Also Like