mohamed faisal
mohamed faisal

Reputation: 446

The type or namespace name 'Chart' does not exist in the namespace 'System.Web.UI.WebControls'

How to solve this error?. I use the same code in different project for chart. I just did the copy paste. But this time it shows this new errors.

I added the references

Reference Files.

UserHomePage.aspx

<asp:Chart ID="ChartHour1001" class="img-responsive" runat="server" Width="800px">
   <Titles>

   </Titles>
       <Series>
           <asp:Series Name="Series1"></asp:Series>
       </Series>
       <ChartAreas>
           <asp:ChartArea Name="ChartArea1">
               <AxisX Title="Hours">
                   <MajorGrid Enabled="false" />
                   <LabelStyle Interval="1" />
               </AxisX>
               <AxisY Title="Sales">
                   <MajorGrid Enabled="false" />
               </AxisY>
           </asp:ChartArea>
       </ChartAreas>
</asp:Chart>

UserHomePage.cs file

 private void getChartData()
    {
        Series series = Chart1.Series["Series1"];
        series.Points.AddXY("1201", "96025.29");
        series.Points.AddXY("1302", "398246.54");
        series.Points.AddXY("1400", "303102.24");
        series.Points.AddXY("2001", "377009.92");
        series.Points.AddXY("2400", "200710.91");

        ///Color[] colors = new Color[] { Color.FromArgb(65,140,240), Color.Green, Color.Wheat, Color.Gray, Color.Blue };
        foreach (Series seriess in Chart1.Series)
        {
            foreach (DataPoint point in seriess.Points)
            {
                //Set color for the bar
                point.Color = colors[series.Points.IndexOf(point)];
            }
        }

        series.IsValueShownAsLabel = true;
    }

But the error is occuring in UserHomePage.designer.cs

protected global::System.Web.UI.WebControls.Chart Chart1; //error occuring Line

web.config

<configuration>
    <configSections>


    </configSections>
    <appSettings>
    <!--ADD this line-->
        <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;"/>
    </appSettings>
    <connectionStrings>
        <!-- I removed Connection String lines -->
</connectionStrings>

<system.web>
    <compilation debug="true" targetFramework="4.5">
        <!-- Removed -->
    </compilation>
    <httpRuntime/>
    <pages controlRenderingCompatibilityVersion="4.0">
        <namespaces>
            <add namespace="System.Web.Optimization"/>
        </namespaces>
        <controls>
            <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/>
    <!--Added new line-->
    <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </controls>
    </pages>
    <authentication mode="Forms">
        <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
    </authentication>
    <profile defaultProvider="DefaultProfileProvider">
        <providers>
            <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/>
        </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
        <providers>
            <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
        </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
        <providers>
            <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/"/>
        </providers>
    </roleManager>
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
        <providers>
            <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection"/>
        </providers>
    </sessionState>
    <httpModules>
        <add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.2, Version=15.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule"/>
    </httpModules>
    <httpHandlers>
<add path="DX.ashx" verb="GET" type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.2, Version=15.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
validate="false" />
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
</httpHandlers>
</system.web>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
        <parameters>
            <parameter value="v13.0"/>
        </parameters>
    </defaultConnectionFactory>
</entityFramework>
<system.webServer>
<modules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.2, Version=15.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
name="ASPxHttpHandlerModule" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ChartImageHandler" />
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.2, Version=15.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
verb="GET" path="DX.ashx" name="ASPxHttpHandlerModule" preCondition="integratedMode" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
<devExpress>
    <themes enableThemesAssembly="true" styleSheetTheme="" theme="" customThemeAssemblies=""/>
    <compression enableHtmlCompression="false" enableCallbackCompression="true" enableResourceCompression="true" enableResourceMerging="true"/>
    <settings doctypeMode="Html5" rightToLeft="false" embedRequiredClientLibraries="false" ieCompatibilityVersion="edge"/>
    <errors callbackErrorRedirectUrl=""/>
</devExpress>
</configuration>

Upvotes: 1

Views: 4103

Answers (1)

Ambrish Pathak
Ambrish Pathak

Reputation: 3968

Try changing

protected global::System.Web.UI.WebControls.Chart Chart1;

To

protected global::System.Web.UI.DataVisualization.Charting.Chart Chart1;

Upvotes: 1

Related Questions