- Home
- Forum
- ASP.NET MVC (Classic)
- Chart reference error
Chart reference error
I have added required references and code from the Sample which you have provided during installation and also used the following link for the reference.
http://help.syncfusion.com/ug_92/User%20Interface/ASP.NET%20MVC/Chart/index.html
I am getting following error.
Error 1 'Syncfusion.Mvc.Shared.ComponentFactory
Please find my code as an attachment also.
You can find the file at the below location.
"~/Views/BasicChartType.cshtml"
SyncfusionMvcApplication1_e79588e.rar
I have resolved the above error but now I am getting some script error. Please fing my code as an attachment,
Thanks
Alok Shah
SyncfusionMvcApplication1_fd3dd8a5.rar
@(new HtmlString(Html.Syncfusion().Chart("chart_Model", (Syncfusion.Mvc.Chart.MVCChartModel)ViewBag.chartModel).ToString())) -- It's working fine
and
@{
Html.Syncfusion().Chart("chart_Model", (Syncfusion.Mvc.Chart.MVCChartModel)ViewBag.chartModel);
} -- It's giving javascript error
Thanks for using Syncfusion products.
By default, razor encodes the HTML. So, we need to use “HtmlString” to render the chart using property model in razor application and also prevent the HTML encoding. In builder model, we are using Render()(for Htmlstring) method to render the chart control. If we are not use “HtmlString” in property model, we got script error due to lack of HtmlString to renderer the control in razor application.
Regards,
Vijayabharathi
I'm having the first error exposed here how it was solved???
The issue with the chart reference.
Thanks,
Hi Manuel,
Thanks for using Syncfusion products.
1)Chart Control
We suspect the cause of issue may be because of not adding required namespace in web.config file. Please refer the below
[Web.config]
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
<add namespace="System.Drawing" />
<add namespace="Syncfusion.Mvc.Shared" />
<add namespace="Syncfusion.Mvc.Chart" />
<add namespace="Syncfusion.Windows.Forms.Chart" />
<add namespace="Syncfusion.Mvc.Tools" />
</namespaces>
If you are using razor sample check this in web.config file available in Views folder. However we have created a simple sample. Please refer the attachment.(Sample_ChartControl)
Also, we are providing Syncfusion project template support to create sample in MVC platform. Please refer the following steps to create a simple chart sample by using template,
1)Open VS2010
2)Choose File->New->Project->New Project dialog opened(Refer projectdialog.png)
3)Choose Syncfusion MVC from this dialog and select Razor MVC3 sample (Refer Projectdialog.png)
4) Select Chart from Syncfusion Wizard and click “Next” button from wizard (Refer SynnWizard.png)
5) Select Theme if you set for control and then click “Done” button from wizard
The chart assemblies and namespace information added in web config files.
2)ChartAdv( Html5 control)
We have created a simple sample for ChartAdv control in MVC platform. Please refer the attachments for this sample(Sample_ChartAdv)
The following steps to create a simple application with ChartAdv control.
1)Create new MVC3 Razor application(Sample_ChartAdv) in VS2010
2) Added below reference assembly in Sample_ChartAdv application
· Syncfusion.Core,
· Syncfusion.Chart.Mvc
· Syncfusion.Shared.Mvc
3) Added code in web config for above assembly and namespace(Refer screenshot webconfig)
4) Added Resource registration to an application (Refer screenshot Layout)
5)Added code for ChartAdv control in view and controller page.
Note: We must add “Syncfusion.Mvc.ChartAdv” namespace in webconfig file for ChartAdv control. Also, we have no separate option to choose ChartAdv(HTML5) from Syncfusion project Template.
Please let us know if any concerns.
Regards,
Vijayabahrathi
Sample_f2000649.zip
Hi Alok,
Thanks for using Syncfusion products.
By default, razor encodes the HTML. So, we need to use “HtmlString” to render the chart using property model in razor application and also prevent the HTML encoding. In builder model, we are using Render()(for Htmlstring) method to render the chart control. If we are not use “HtmlString” in property model, we got script error due to lack of HtmlString to renderer the control in razor application.
Regards,
Vijayabharathi
[email protected]
- 7 Replies
- 5 Participants
-
AD Administrator
- Aug 1, 2011 06:01 AM UTC
- Apr 5, 2018 09:45 AM UTC