在UpdatePanel中使用listview进行分页局部更新时,默认情况下,在IE中可能会出现“Sys.WebForms.PageRequestManagerServerErrorException: An unknow error occurred while processing the request on the server . The status code returned from the server was: 12031”或代号为404,示例代码如下:
<asp:UpdatePanel ID="UpdatePanelTest" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:ListView ID="ListView2" runat="server" DataKeyNames="WorkId"
DataSourceID="SqlDataSource1">
<ItemTemplate>
<tr style="background-color: #FFFFFF;color: #000000;">
<td>
<asp:Label ID="WorkContentLabel" runat="server" Text='<%# Eval("WorkContent") %>' /></td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
目前还没有数据可以显示</td>
</tr>
</table>
</EmptyDataTemplate>
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #000000;border-style:solid;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif; padding:6px; margin:0px; text-align:center">
<tr id="Tr2" runat="server" style="background-color: #859CB6; color: #006666; font-size: 15pt; font-weight: bold; text-align:center">
<th id="Th1" runat="server">序号</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server"
style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF">
<asp:DataPager ID="DataPager2" runat="server" PageSize="5">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="true" ShowNextPageButton="true" ShowPreviousPageButton="true" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
但是上述错误在firefox中却没有,本人调试了两天,终于解决了问题,方法如下:
在本页面script脚本的开始出加入:
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
Sys.Application.add_load(function()
{
var form = Sys.WebForms.PageRequestManager.getInstance()._form;
form._initialAction = form.action = window.location.href;
});
即可,至于原理,可参照http://www.pin5i.com/showtopic-26101.html所述