Error creating control - Chart 1 with ASP.NET Chart

Answered Error creating control - Chart 1 with ASP.NET Chart

  • 2012년 3월 7일 수요일 오전 5:39
     
      코드 있음

    I need to create a sharepoint 2010 web part with Visual studio 2010. My web part need to show ASP.NET Chart.

    To create this web part I added Visual Web Part Option from the SharePoint Installed templates in VS 2010. and then I dragged ASP.NET Chart control. But when i add this ASP.NET chart to the VS 2010 it shows me an error : Error creating control - Chart 1 Object reference not set to an instance of an object.

    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %> 
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Sh_ViolationGraphUserControl.ascx.cs" Inherits="NWC.iReports.Sh.Sh_ViolationGraph.Sh_ViolationGraphUserControl" %>
    <%@ Register Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
    
    
    <asp:Chart ID="Chart1" runat="server">
        <Series>
            <asp:Series Name="Series1">
            </asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1">
            </asp:ChartArea>
        </ChartAreas>
    </asp:Chart>
    

    This is the code. 

    So please help me to how I can add a ASP.NET chart control to a SharePoint user control page.

    Note: I created a separate ASP.NET web site by using VS 2010 and then added this control then its work fine. So the problem is while adding to the SharePoint web part

    Regards

    Shaji


    I am new to SharePoint

모든 응답

  • 2012년 3월 7일 수요일 오후 1:46
     
     답변됨 코드 있음

    As per the code you pasted above i can see two assemblies are registered with same prefix as below

    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Register Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>

    Use different prefix for second assembly and then initialize control with new prefix.

    w: blog.sandippatil.com | t: @sharesandip

  • 2012년 3월 7일 수요일 오후 3:20
     
     
    did you register the System.Web.DataVisualization as safecontrol?
  • 2012년 4월 23일 월요일 오후 9:21
     
     

    which prefix can we use?? I see that the error only happens when using webparts

  • 2012년 5월 29일 화요일 오전 1:47
     
     
    Did you find any solution to this issue?