Hello,
Exception Details:System.InvalidOperationException: Script controls may not be registeredafter PreRender.
Source Error:
Stack Trace:
I have a RadGrid with the export to excel command enabled, and a RadFilter to filter the grid data.
When I try to export the grid to excel after applying filters, an exception occurs.
But the grid exports fine to excel if no filters are applied.
Please explain how to fix or workaround the problem.
Exception Info:
Script controls may not be registered after PreRender.
Description:An unhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about the error andwhere it originated in the code.Exception Details:System.InvalidOperationException: Script controls may not be registeredafter PreRender.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
|
Aspx snippets:
<script type="text/javascript"> |
//<![CDATA[ |
function RequestStart(sender, args) { |
if (args.get_eventTarget().indexOf("ExportToExcelButton") != -1) { |
args.set_enableAjax(false); |
} |
} |
//]]> |
</script> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> |
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" onajaxrequest="RadAjaxManager1_AjaxRequest" ClientEvents-OnRequestStart="RequestStart"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="gridClientes" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
<telerik:AjaxSetting AjaxControlID="gridClientes"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="gridClientes" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
<ClientEvents OnRequestStart="RequestStart" /> |
</telerik:RadAjaxManager> |
<div><telerik:RadFilter ID="RadFilter1" runat="server" FilterContainerID="gridClientes" ShowApplyButton="True" /></div> |
<telerik:RadGrid ID="gridClientes" runat="server" GridLines="None" |
AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" |
OnSortCommand="gridClientes_SortCommand" OnPageIndexChanged="gridClientes_PageIndexChanged" OnPageSizeChanged="gridClientes_PageSizeChanged" |
OnNeedDataSource="gridClientes_NeedDataSource" OnItemCommand="gridClientes_ItemCommand" OnUpdateCommand="gridClientes_UpdateCommand" OnItemDataBound="gridClientes_ItemDataBound" |
PageSize="50"> |
<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" EditMode="InPlace"> |
<CommandItemSettings ShowExportToExcelButton="true" ExportToExcelText="Exportar a Excel" ShowRefreshButton="False" ShowAddNewRecordButton="False" /> |
<Columns> |
<Columns> |
<telerik:GridBoundColumn DataField="Field1" SortExpression="Field1" UniqueName="Field1"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field2" SortExpression="Field2" UniqueName="Field2"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field3" SortExpression="Field3" UniqueName="Field3"></telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
<ClientSettings EnableRowHoverStyle="True" ReorderColumnsOnClient="True" AllowColumnsReorder="True"> |
<ClientEvents OnRowSelected="gridClientes_OnRowSelected" /> |
<Selecting AllowRowSelect="True" /> |
<Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling> |
<Resizing AllowColumnResize="true" /> |
</ClientSettings> |
<ExportSettings FileName="clientes" OpenInNewWindow="True" IgnorePaging="True" Excel-Format="ExcelML" ExportOnlyData="True"></ExportSettings> |
<PagerStyle AlwaysVisible="true" Position="Bottom" /> |
</telerik:RadGrid> |
Thanks in advance.