- Home
- Forum
- ASP.NET Web Forms
- DateTimeAxis Chart ruins my page
DateTimeAxis Chart ruins my page
Hello again.
Attachment: Holod_r_1_syncfusion_d0e2aa31.7z
Found new problem n my code. Help me please. I use https://help.syncfusion.com/file-formats/xlsio/working-with-charts + http://asp.syncfusion.com/demos/web/chart/datetimeaxis.aspx in 1 page. First time i added button with XlsxIO logic and it works well. But then i add DateTimeAxis Chart like in example and now it is not working. Chart builds well, but when i want to export data in xlsx i get a error page:
[HttpRequestValidationException (0x80004005): Обнаружено потенциально опасное значение Request.Form, полученное от клиента (MainContent_Chart1_hidden_model="...point.x# <br/> Profit : #poin...").]
System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection) +9809832
System.Web.<>c__DisplayClass280_0.<ValidateHttpValueCollection>b__0(String key, String value) +22
System.Web.HttpValueCollection.EnsureKeyValidated(String key) +9807829 ...Source file: C:\Users\sobolevis\AppData\Local\Temp\Temporary ASP.NET Files\root\dc0da1df\e0565dbe\App_Web_k244sp53.3.cs Строка: 0
[IMG]http://i68.tinypic.com/286xs34.png[/IMG]
Chart code:
<div>
<script type="text/javascript" src="../Scripts/ChartData.js"></script>
<ej:WaitingPopup runat="server" ID="waitingpopup" ShowOnInit="false"></ej:WaitingPopup>
<ej:Chart ID="Chart1" runat="server" Width="970" Height="600" IsResponsive="true" OnClientLoad="onChartLoad">
<PrimaryXAxis ValueType="Datetime" LabelFormat="MM-dd HH:mm" IntervalType="Hours" Title-Text="Datetime" />
<PrimaryYAxis LabelFormat="{value}°С" Title-text="Temperature" />
<Series>
<ej:Series EnableAnimation="True" Type="Line" Name="Sales" XName="Xvalue" YName="YValue1"
Border-Width="3" Marker-Visible="true" Marker-Size-Height="10" Marker-Size-Width="10" Tooltip-Visible="true"
Tooltip-Format="Date : #point.x# <br/> Profit : #point.y#"></ej:Series>
</Series>
<Legend Visible="true"></Legend>
</ej:Chart>
</div>
Project in attachment. I tied to use validateRequest="false" but it does not work.
Attachment: Holod_r_1_syncfusion_d0e2aa31.7z
SIGN IN To post a reply.
4 Replies
IL
Ilya
November 29, 2016 12:12 PM UTC
Try to translate 1st yellow string: Founded potentional danger value Request.Form, received from client (MainContent_Chart1_hidden_model="...point.x# <br/> Profit : #poin...").]
And add the aspx.cs code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Syncfusion.XlsIO;
using System.Data.OleDb;
using System.IO;
using System.Drawing;
using System.Collections;
namespace Holod_r_1
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Setting Range for PrimaryXAxis
this.Chart1.PrimaryXAxis.Range.Min = new DateTime(2000, 06, 06, 23, 55, 00);
this.Chart1.PrimaryXAxis.Range.Max = new DateTime(2000, 06, 10, 01, 10, 34);
this.Chart1.PrimaryXAxis.Range.Interval = 6;
System.Collections.Generic.List<DatetimeData> data = new System.Collections.Generic.List<DatetimeData>();
data.Add(new DatetimeData(new DateTime(2000, 06, 07, 23, 55, 00), 10));
data.Add(new DatetimeData(new DateTime(2000, 06, 08, 01, 10, 05), -30));
data.Add(new DatetimeData(new DateTime(2000, 06, 08, 02, 25, 59), 15));
data.Add(new DatetimeData(new DateTime(2000, 06, 08, 03, 40, 45), -65));
data.Add(new DatetimeData(new DateTime(2000, 06, 08, 04, 55, 44), 90));
data.Add(new DatetimeData(new DateTime(2000, 06, 08, 05, 10, 34), 85));
data.Add(new DatetimeData(new DateTime(2000, 06, 08, 06, 55, 00), 10));
data.Add(new DatetimeData(new DateTime(2000, 06, 09, 08, 10, 05), -30));
data.Add(new DatetimeData(new DateTime(2000, 06, 09, 10, 25, 59), 15));
data.Add(new DatetimeData(new DateTime(2000, 06, 09, 12, 40, 45), -65));
data.Add(new DatetimeData(new DateTime(2000, 06, 09, 15, 55, 44), 90));
data.Add(new DatetimeData(new DateTime(2000, 06, 09, 18, 10, 34), 85));
//Binding Datasource to Chart
this.Chart1.DataSource = data;
this.Chart1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Inserts the sample data for the chart
sheet.Range["A1"].Text = "Month";
sheet.Range["B1"].Text = "Product A";
sheet.Range["C1"].Text = "Product B";
//Months
sheet.Range["A2"].Text = "Jan";
sheet.Range["A3"].Text = "Feb";
sheet.Range["A4"].Text = "Mar";
sheet.Range["A5"].Text = "Apr";
sheet.Range["A6"].Text = "May";
//Create a random Data
Random r = new Random();
for (int i = 2; i <= 6; i++)
{
for (int j = 2; j <= 3; j++)
{
sheet.Range[i, j].Number = r.Next(0, 500);
}
}
IChartShape chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set Chart Title
chart.ChartTitle = "Product Sales comparison";
//Set first serie
IChartSerie productA = chart.Series.Add("ProductA");
productA.Values = sheet.Range["B2:B6"];
productA.CategoryLabels = sheet.Range["A2:A6"];
//Set second serie
IChartSerie productB = chart.Series.Add("ProductB");
productB.Values = sheet.Range["C2:C6"];
productB.CategoryLabels = sheet.Range["A2:A6"];
workbook.SaveAs("chart.xlsx", ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog);
workbook.Close();
excelEngine.Dispose();
}
}
[Serializable]
public class DatetimeData
{
public DatetimeData(DateTime xval, double yvalue1)
{
this.Xvalue = xval;
this.YValue1 = yvalue1;
}
public DateTime Xvalue
{
get;
set;
}
public double YValue1
{
get;
set;
}
}
}
DD
Dharanidharan Dharmasivam
Syncfusion Team
November 30, 2016 08:44 AM UTC
Hi Ilya,
Thanks for using Syncfusion product. Kindly find the response for your queries below.
Query 1 & 2: when i want to export data in xlsx i get a error page & Try to translate 1st yellow string
Response: We have analyzed your query with the provided sample. The error is due to usage of <br> tag in the tooltip format property. For security purpose in ASP, html tags are blocked. To overcome this, we have logged feature request for this and will be available in any of our upcoming Essential Studio release. For better follow up regarding the feature, we have created branch incident (#168324) under your account, so follow up with incident 168324.
Also your requirement for tooltip can be achieved by using Tooltip-Template property. By using this property, you will not get any errors as you mentioned and also you can export as excel format. Kindly find the code snippet.
|
ASP.NET:
<div id="Tooltip" style="display: none; color: white; margin-left: 1px;">
<div id="efpercentage">Date: #point.x#</div>
<div id="ef">Profit: #point.y#</div>
</div>
<ej:Chart ID="Chart1" runat="server">
<Series>
<ej:Series Tooltip-Visible="true" Tooltip-Template="Tooltip">
</ej:Series>
</Series>
</ej:Chart> |
Screenshot:
For your reference we have attached the sample. Kindly find the sample from below location,
Thanks,
Dharani.
IL
Ilya
December 1, 2016 06:58 AM UTC
Thank you. Now it works well. But this error is in example: Example . I wish you will edit it)
DD
Dharanidharan Dharmasivam
Syncfusion Team
December 2, 2016 09:48 AM UTC
Hi Ilya,
Thanks for your update.
As mentioned in the previous update, if you perform any action in server side with html tags, the issue will occur due to security purpose in ASP, html tags are blocked. In the sample which you have mentioned, we didn’t perform server side operation, so this will not cause issue.
Thanks,
Dharani.
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
-
IL Ilya
- Nov 29, 2016 12:08 PM UTC
- Dec 2, 2016 09:48 AM UTC