簡體   English   中英

錯誤:此頁面的狀態信息無效,並且可能已損壞

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

我看到錯誤:

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

在我的頁面上。 根據一些閱讀,我認為該錯誤可能由於多種原因而發生,並且可能很難解決。

在aspx頁面上,我有兩個下拉控件:

<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>

在文件背后的代碼中,我使用ajax根據從第一個下拉菜單中選擇的值來更新和重建第二個下拉選項:

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

有時下拉列表中的get會被填充,但是大多數情況下會引發錯誤。

您正在動態更改頁面(服務器端控件),這將更改頁面的view state ,因此在回發時,ASP.NET會解密view state並且與預期view state不匹配。

我遇到了這個問題,花了很長時間才能在我的《守則》中解決。


第一件事是我有UpdatePanel和一個jquery對話框。 以下是我正在使用的腳本。

<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>

這是表格

<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>

在這里,我們看到我在Button控件中使用服務器端和客戶端腳本。 對於他們兩個而言,重要的是從對話框中刪除form標記,將腳本放入UpdatePanel並設置UseSubmitBehaviour =“ false”。 這將導致對話框回發,這是我們需要在服務器端執行的操作。

最初我有表單標簽。 刪除表單標記后,它會同時執行事件OnClientClick和OnClick服務器端事件。 干杯! 如果有人有這個問題,這里就是解決方案。

以下問題終於解決:

  1. 客戶端事件執行。
  2. 通過jQuery-UI對話框彈出服務器端事件。
  3. 進行PostBack的對話框,這意味着我們可以在對話框內部擁有完整的帶有控件的ASP.NET表單。
  4. 解決了“狀態信息對此頁面無效並可能已損壞”的問題。

注意:我在表單內使用DetailsView控件。

干杯!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM