"View State Invalid" Error While Submitting Form thru JavaScript

Discussion in 'ASP .Net' started by Vinod I, Feb 16, 2004.

  1. Vinod I

    Vinod I Guest

    Hi Team,

    When I tryed following code, I am getting the Runtime Error as
    "The View State is invalid for this page and might be corrupted."
    Exception Details: System.Web.HttpException: The View State is invalid for
    this page and might be corrupted.
    Stack Trace:
    [HttpException (0x80004005): The View State is invalid for this page and
    might be corrupted.]
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +150
    System.Web.UI.Page.LoadPageViewState() +16
    System.Web.UI.Page.ProcessRequestMain() +421



    And My Code is in ".js" file:
    function save()

    {

    document.forms(0).method = "post";

    document.forms(0).action = "formsave1.aspx";

    document.forms(0).submit();

    }

    Please let me know wat can be the reason.

    Thanks in advance..

    cheers !!
    Vinod I, Feb 16, 2004
    #1
    1. Advertising

  2. Vinod I

    matt Guest

    If you change the action attribute of the form then the Viewstate will
    become invalid, you will be posting back data to a different place. The
    idea with a webform is that it is always posted back to itself, viewstate is
    loaded so your page knows when to run onchange, onclick.. etc server side
    events. If you postback to a different page then there would be no way of
    knowing if the controls would be the same (and if they were what would be
    the point of having a separate webform anyway).

    Hope that helps you solves your problem, the only time I can think of that
    you would want to overwrite the action attribute using Javascript is if you
    have made a previous call to Context.Rewritepath in an HttpModule. You
    could then use Javascript to correct the incorrect action attribute that is
    output by ASP.net, which causes exactly the same error you are seeing.

    Matt
    http://www.3internet.com
    Inigo Content Management - c# asp.net cms


    "Vinod I" <> wrote in message
    news:...
    > Hi Team,
    >
    > When I tryed following code, I am getting the Runtime Error as
    > "The View State is invalid for this page and might be corrupted."
    > Exception Details: System.Web.HttpException: The View State is invalid for
    > this page and might be corrupted.
    > Stack Trace:
    > [HttpException (0x80004005): The View State is invalid for this page and
    > might be corrupted.]
    > System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +150
    > System.Web.UI.Page.LoadPageViewState() +16
    > System.Web.UI.Page.ProcessRequestMain() +421
    >
    >
    >
    > And My Code is in ".js" file:
    > function save()
    >
    > {
    >
    > document.forms(0).method = "post";
    >
    > document.forms(0).action = "formsave1.aspx";
    >
    > document.forms(0).submit();
    >
    > }
    >
    > Please let me know wat can be the reason.
    >
    > Thanks in advance..
    >
    > cheers !!
    >
    >
    matt, Feb 16, 2004
    #2
    1. Advertising

  3. Your post went unanswered. Have you resolved this issue?

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Vinod I" <> wrote in message
    news:...
    > Hi Team,
    >
    > When I tryed following code, I am getting the Runtime Error as
    > "The View State is invalid for this page and might be corrupted."
    > Exception Details: System.Web.HttpException: The View State is invalid for
    > this page and might be corrupted.
    > Stack Trace:
    > [HttpException (0x80004005): The View State is invalid for this page and
    > might be corrupted.]
    > System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +150
    > System.Web.UI.Page.LoadPageViewState() +16
    > System.Web.UI.Page.ProcessRequestMain() +421
    >
    >
    >
    > And My Code is in ".js" file:
    > function save()
    >
    > {
    >
    > document.forms(0).method = "post";
    >
    > document.forms(0).action = "formsave1.aspx";
    >
    > document.forms(0).submit();
    >
    > }
    >
    > Please let me know wat can be the reason.
    >
    > Thanks in advance..
    >
    > cheers !!
    >
    >
    Alvin Bruney [MVP], Mar 2, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Smithz
    Replies:
    3
    Views:
    34,570
    mokker
    Oct 30, 2009
  2. THTB
    Replies:
    0
    Views:
    173
  3. Max Williams
    Replies:
    3
    Views:
    157
    Robert Klemme
    Jan 6, 2009
  4. Karuna

    Problem while submitting FORM data

    Karuna, Aug 5, 2004, in forum: Javascript
    Replies:
    2
    Views:
    117
    Marcel van den Brink
    Aug 6, 2004
  5. Prad
    Replies:
    0
    Views:
    208
Loading...

Share This Page