简体   繁体   中英

Error: The state information is invalid for this page and might be corrupted

I'm seeing the error:

The state information is invalid for this page and might be corrupted

On my page. Based on some reading, I gather that the error can occur due to several reasons, a and can be quite difficult to troubleshoot.

On the aspx page I have two drop down controls:

<asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="dsClients" DataTextField="Client_Name" DataValueField="Client_Name" AutoPostBack="True" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" ondatabound="DropDownList3_DataBound"></asp:DropDownList>
<asp:DropDownList ID="ddQualIDInsert" runat="server" DataSourceID="dsQual" DataTextField="Project_Name" DataValueField="Qual_ID"></asp:DropDownList>

In the code behind file I use ajax to update and rebuild the second drop down option based on the selected value from the first drop down menu:

protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
   dsQual.Where = "Client_Name = \"" + ((DropDownList)sender).SelectedValue +"\"";
}

The drop down get's per-populated sometimes, however mostly throws the error.

您正在动态更改页面(服务器端控件),这将更改页面的view state ,因此在回发时,ASP.NET会解密view state并且与预期view state不匹配。

I got this issue and it took me a long time to resolve it in my Code.


First thing is I had UpdatePanel and a jquery dialog. Below is the script I am using.

<script>
     var uiDialog = $('.ui-dialog-container').parent();
     (uiDialog.next().length && uiDialog.appendTo((document.forms.item(0) != null) ?   document.forms.item(0) : document.body));
     //verifyUser();
     function ShowDialog() {

         dialog = $("#dialog-form").dialog({
             autoOpen: true,
             resizable: false,
             height: 400,
             width: 800,
             modal: true,
             overlay: {
                 backgroundColor: '#000',
                 opacity: 0.5
             }


         });
     }



</script>

This is the form

<div id="dialog-form" title="Verify Transaction" style="display:none;" >
    <asp:ScriptManager ID="ScriptManager2" runat="server"  />


            <fieldset style="background-color:#ffd800;border-radius:5px;">

            <label for="fname">First Name    :</label>
            <label for="fname"><%= DetailsView1.Rows[7].Cells[1].Text %></label><br />

            <label for="lname">Last Name     :</label>
            <label for="lname"><%= DetailsView1.Rows[9].Cells[1].Text %></label><br />

            <label for="zip">Zip Code        :</label>
            <label for="zip"><%= DetailsView1.Rows[22].Cells[1].Text %></label><br />



            </fieldset>
    <hr />
    <asp:Button id="btnVerified" runat="server" OnClick="btnVerify_Click" UseSubmitBehavior="false" Text="Verified" />
            <asp:Button ID="btnCancelled" runat="server" OnClientClick="dialog.dialog('close')" Text="Cancelled" UseSubmitBehaviour="false"/>


</div>

Here we see that I am using server side and client side script in the Button Control. The important thing for both of them to work is remove the form tag from the dialog , put the script in UpdatePanel and set UseSubmitBehaviour="false". This will cause the dialog to postback which is what we need to go to server-side.

Initially I had form tags. Once I removed the form tag it executed both the events OnClientClick and OnClick server side events executed. Cheers !! If any body has this issue here is the solution.

Following issues got finally resolved :

  1. Client-Side Event execution.
  2. Server-Side Event execution with jQuery-UI dialog pop-up.
  3. Dialog doing a PostBack which means that we can have a complete ASP.NET Form with Controls inside the dialog.
  4. The issue of 'state information invalid for this page and might be corrupted' got resolved.

Note : I am using DetailsView Control inside the form.

Cheers !!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM