Hi all,
I have a default page which is ajax enabled. From here I open a report.aspx page which is loaded into a radwindow. The report.aspx page is just a grid with data. When I try and export this data I get the error:
"
"
I'm not sure why I'm getting this. Can someone please help me find the solution? Code below: Thanks!
Report.aspx
Report.aspx.cs
I have a default page which is ajax enabled. From here I open a report.aspx page which is loaded into a radwindow. The report.aspx page is just a grid with data. When I try and export this data I get the error:
"
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation
"
I'm not sure why I'm getting this. Can someone please help me find the solution? Code below: Thanks!
Report.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="quick_transaction_popup.aspx.cs" Inherits="OnTime.OnTime_Reports.Visitors.quick_transaction_popup" %><%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <telerik:RadScriptManager ID="Report_ScriptManager" runat="server" /> <h3> <asp:Literal ID="Literal_View1_Title" runat="server" Text="Transactions: Quick Report - "></asp:Literal> </h3> <asp:PlaceHolder ID="PlaceHolder_Report_SQL" runat="server"> <asp:SqlDataSource ID="SqlDataSource_Report" runat="server"> </asp:SqlDataSource> </asp:PlaceHolder> <telerik:RadGrid ID="RadGrid_Report" runat="server" AutoGenerateColumns="false" AllowMultiRowSelection="false" AllowAutomaticInserts="false" GridLines="None" CellPadding="0" AllowSorting="false" Skin="Outlook" ItemStyle-VerticalAlign="Top" OnExcelMLExportRowCreated="RadGrid_Report_ExcelMLExportRowCreated" Width="100%" > <ExportSettings HideStructureColumns="true" ExportOnlyData="true" FileName="Visitor_TQR" OpenInNewWindow="true" IgnorePaging="true"> <Excel Format="ExcelML" /> </ExportSettings> <MasterTableView Width="100%" CommandItemDisplay="Top" GridLines="None" AllowAutomaticInserts="false"> <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToWordButton="false" ShowExportToExcelButton="true" ShowExportToCsvButton="false" ShowRefreshButton="false"/> <Columns> <telerik:GridBoundColumn UniqueName="Report_Logs_DateTime" DataField="Visitor_Logs_DateTime" HeaderText="Time" HeaderStyle-Width="33%" Visible="true" ItemStyle-VerticalAlign="Top"/> <telerik:GridBoundColumn UniqueName="Report_Transaction_Type" DataField="Function_Key_Description" HeaderText="Transaction Type" HeaderStyle-Width="33%" Visible="true" ItemStyle-VerticalAlign="Top"/> <telerik:GridBoundColumn UniqueName="Report_UserName" DataField="Visitor_UserName" HeaderText="Visitor" HeaderStyle-Width="33%" Visible="true" ItemStyle-VerticalAlign="Top"/> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="false" /> </ClientSettings> </telerik:RadGrid> </div> </form></body></html>Report.aspx.cs
protected void Page_Load(object sender, EventArgs e) { //Register Javascript for Export Buttons string script2 = "function onRequestStart(sender, args)" + "{" + "if (args.get_eventTarget().indexOf(\"ExportToExcelButton\") >= 0 ||" + "args.get_eventTarget().indexOf(\"ExportToWordButton\") >= 0 ||" + "args.get_eventTarget().indexOf(\"ExportToCsvButton\") >= 0)" + "{" + "args.set_enableAjax(false);" + "}" + "}"; //I've tried commenting and UN-commenting this line with no luck! //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Report_RadGrid_Ajax_Disable", script2, true); Display_Report_RadGrid(); } protected void Display_Report_RadGrid() { //Populate Rad Grid SqlDataSource_Report = new SQL_Data_Source().getSQLDataSource(); SqlDataSource_Report.SelectCommandType = SqlDataSourceCommandType.StoredProcedure; SqlDataSource_Report.SelectCommand = SQL_Customer_Connection.Product_Name + "_rp_Visitor_TQR"; SqlDataSource_Report.SelectParameters.Add("Param_Customer_ID_Ref", TypeCode.String, (string)Session["User_Belongs_To_Customer_Ref_ID"]); SqlDataSource_Report.SelectParameters.Add("Param_Company_ID_Ref", TypeCode.String, (string)Session["User_Belongs_To_Company_Ref_ID"]); SqlDataSource_Report.SelectParameters.Add("Param_Visitor_Auto_ID_Ref", TypeCode.Int32, "22"); SqlDataSource_Report.SelectParameters.Add("Param_Transaction_Types", TypeCode.String, "0,1,2,3,4,5,6,7,8"); SqlDataSource_Report.SelectParameters.Add("Param_Start_Date", TypeCode.DateTime, "2011-01-01"); SqlDataSource_Report.SelectParameters.Add("Param_End_Date", TypeCode.DateTime, "2012-01-01"); RadGrid_Report.DataSource = SqlDataSource_Report; RadGrid_Report.Rebind(); } bool ExcelML_isConfigured = false; protected void RadGrid_Report_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e) { if (e.RowType == GridExportExcelMLRowType.DataRow) { //Add custom styles to the desired cells if (!ExcelML_isConfigured) { //Set Worksheet name e.Worksheet.Name = "Visitor_TQR"; //Set Column widths foreach (ColumnElement column in e.Worksheet.Table.Columns) { switch (e.Worksheet.Table.Columns.IndexOf(column)) { case 1: column.Width = Unit.Point(100); break; case 2: column.Width = Unit.Point(150); break; case 3: column.Width = Unit.Point(150); break; } } //Set Page options PageSetupElement pageSetup = e.Worksheet.WorksheetOptions.PageSetup; pageSetup.PageLayoutElement.IsCenteredVertical = true; pageSetup.PageLayoutElement.IsCenteredHorizontal = true; pageSetup.PageMarginsElement.Left = 0.5; pageSetup.PageMarginsElement.Top = 0.5; pageSetup.PageMarginsElement.Right = 0.5; pageSetup.PageMarginsElement.Bottom = 0.5; //pageSetup.PageLayoutElement.PageOrientation = PageOrientationType.Landscape; //Freeze panes e.Worksheet.WorksheetOptions.AllowFreezePanes = true; e.Worksheet.WorksheetOptions.LeftColumnRightPaneNumber = 1; e.Worksheet.WorksheetOptions.TopRowBottomPaneNumber = 1; e.Worksheet.WorksheetOptions.SplitHorizontalOffset = 1; e.Worksheet.WorksheetOptions.SplitVerticalOffest = 1; e.Worksheet.WorksheetOptions.ActivePane = 2; ExcelML_isConfigured = true; } } }