C# 错误:此页的状态信息无效,可能已损坏

C# 错误:此页的状态信息无效,可能已损坏,c#,asp.net,asp.net-3.5,C#,Asp.net,Asp.net 3.5,我看到了错误: The state information is invalid for this page and might be corrupted 在我的页面上。根据一些阅读资料,我推断错误可能是由于多种原因造成的,并且很难排除故障 在aspx页面上,我有两个下拉控件: <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="dsClients" DataTextField="Client_Name" D

我看到了错误:

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>

下拉列表get's per populated有时会出现错误。

您正在动态更改页面(服务器端控件),这会更改页面的查看状态,因此在回发时,ASP.NET解密的
视图状态
与预期状态不匹配。

我遇到了这个问题,在代码中花了很长时间才解决


首先,我有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>

var uiDialog=$('.ui对话框容器').parent();
(uiDialog.next().length&&uiDialog.appendTo((document.forms.item(0)!=null)?document.forms.item(0):document.body));
//验证用户();
函数ShowDialog(){
对话=$(“#对话形式”)。对话({
自动打开:对,
可调整大小:false,
身高:400,
宽度:800,
莫代尔:是的,
覆盖:{
背景颜色:“#000”,
不透明度:0.5
}
});
}
这是表格

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

名字:

姓氏:
邮政编码:

这里我们看到我在按钮控件中使用服务器端和客户端脚本。对于这两种方法来说,重要的是从对话框中删除表单标记,将脚本放入UpdatePanel并设置UseSubmitBehaviour=“false”。这将导致对话框回发,这正是我们需要转到服务器端的地方

最初我有表单标签。一旦我删除了表单标记,它就执行了已执行的事件OnClientClick和OnClick服务器端事件。干杯如果任何机构有这个问题,这里是解决办法

以下问题最终得到解决:

  • 客户端事件执行
  • 使用jQuery UI对话框弹出的服务器端事件执行
  • 对话框进行回发,这意味着我们可以拥有一个完整的ASP.NET表单,其中包含对话框中的控件
  • “状态信息对此页无效,可能已损坏”的问题已得到解决
  • 注意:我正在表单中使用DetailsView控件


    干杯

    删除任何非服务器端控件或解释您需要什么,然后我们可以提供更多帮助。我需要根据从另一个下拉列表(DropDownList3)中选择的值,使用ajax更新下拉列表(DDQualitInsert)中的值。然后不要从客户端自己更新它。使用AJAX下拉列表并触发它进行自我更新。
    <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>