How to use chart control's assemblies in application without installing it? - asp.net

I am using a web application in which there is a chart control. I had installed the Microsoft chart control exe and Visual studio add on.
The problem is that when I upload the application on the server, there is a problem with the two assemblies missing System.Web.DataVisualization.Design.dll and System.Web.DataVisualization.dll.
So, I want to uninstall the Microsoft chart control exe & Visual studio add on, and instead only use the DLL in the application by giving reference in it.
Now, how do I define chart control on an ASPX page? How do I register the assemblies on the ASPX page and how can I get the chart control from it?

I think you can just add the DLL's to your Bin directory of your website.
Installing the chart controls locally simply adds the DLL's to your computer somewhere (I think). And I believe that the Add-In is to give you support for design mode. It doesn't install anything specific to your projects.
However, you may need to register the controls either on the page or in the web.config. For example, here is the registration of the AjaxControlToolkit controls in the web.config:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<pages>
<controls>
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
</pages>
</system.web>
</configuration>

I have solved the problem.
First, add the library System.Web.DataVisualization.dll as reference.
Then, add the following line in web.config, inside <httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
You may see DataVisualization.Charting.ChartHttpHandler in red, it will build and run successfully. This may be a ReSharper bug.

Related

How to add ajax control in the project

I am using asp.net using C#.I want to add Ajax Control to my Web Pages.I am using visual studio 2005.That had ajax basic control not extended control and bin folder contain ajax controltoolkit.dll.But when I am adding control to my page,it shows the unknown elements.I add references and select that file(dll).Still the assembly details is not coming in my aspx page.And still saying unknown element.I have another project also.In that I done same ,and it works also.
You'll need to edit your web.config
<add assembly="AjaxControlToolkit, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
Goes between
<assemblies></assemblies>
tag.
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
Goes between
<controls></controls>
tag.

asp.net mvc deployment

Ive managed to get asp.net mvc up and running on an iis6 server, but I keep getting silly messages like 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial'
I've got all the required dlls and even installed mvc from
http://www.microsoft.com/downloads/details.aspx?FamilyID=c9ba1fe1-3ba8-439a-9e21-def90a8615a9&displaylang=en
any clues about what Im missing?
Cheers
RenderPartial is an extension method and is defined in System.Web.Mvc.
So check out if you have in root Web.config lines adding System.Web.Extensions assembly:
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
in <configuration> <system.web> <compilation> <assemblies> node.
Thanks all for your suggestions and also more importantly for your contributions which has made this site the great site. I dont know what I would do without this site and you guys. Thanks
this link fixed it, replacing the compilers section of the web config did it 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial' - ASP.Net MVC
You are most probably missing this from your web.config:
<add namespace="System.Web.Mvc.Html"/>

I don't have ListView in toolbox, intellisense, and doens't work in code

I am using ASP.NET v3.5 and Visual Studio 2008. For some reason ListView doesn't appear in my toolbox, it doesn't show up in intellisense when coding, and if I try to include one anyways I can't access it from code behind (will give error saying it isn't declared). What am I missing here.... where is my listview!?
Update: I have v3.5 installed but for some reason the project is using 2.0... now on to figure out how to change that. In my project references several things say version 3.5.0.0 and several say 2.0.0.0 .... is there any way to update everything to version 3.5 ???
Try changing your project's TargetFramework to 2.0 and follow VS.NET's instructions to reload project. Then change the TargetFramework back to 3.5 and follow instructions.
It worked for me to get the asp:ListView back into intellisense.
Not sure what gets VS.NET in this state though.
Does your project reference System.Web.Extensions? You will need to do so to get at the new ListView control.
Make sure you have a FQ assembly reference to the 3.5 version of System.Web.Extensions, in the web.config section.
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Also make sure you have a FQ assembly reference in the <system.web><compilation><assemblies> web.config section too.

ASP.NET MVC AJAX Sys is undefined error

I am getting a "Microsoft JScript runtime error: 'Sys' is undefined" error on one of my pages in an MVC application when I attempt an AJAX call. The AJAX call is made from a partial view which is embedded in more than one page. It works fine on all of the pages except one. I have read posts pointing to the web.config file settings and .axd mappings as possible solutions, but the application is configured correctly in the web.config, and the .axd mappings are also correct in IIS. Plus it works fine on all of the pages that use this partial view except one. It is acting like the AJAX libraries are not loading for this one page.
The references to the script files are in the shared site.master file. All of the pages, including the one that doesn't work, reference the same masterpage.
Any ideas? I have been working on this one for two days now. Thanks.
EDIT: As Sam pointed out below, it would seem like the AJAX call is firing before the AJAX libraries have a chance to load. But, the AJAX call is triggered by a submit button long after the page has rendered, so the AJAX libraries have had plenty of time to load - sorry for not giving enough information the first time.
In web.config add the following line of code under appsettings tag:
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
Just in case... use the following to avoid path issues
<script src="<%= Url.Content("~/Scripts/MicrosoftAjax.debug.js") %>"
type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.debug.js") %>"
type="text/javascript"></script>
Source: http://msdn.microsoft.com/en-us/library/dd381533.aspx
Thanks,
Arty
Load the page in Firefox, then use Firebug to inspect the page - you will be able to see all the individual scripts that have been loaded, plus all the network requests that were issued, and whether they succeeded or not. This is better than trying to troubleshoot from the server perspective.
If you are using IE8, you can use the Developer Tools window, but I think Firebug is better - both tools support JavaScript debugging though.
The most likely problem is that you are running script in your partial view before the scripts it is dependent on have had a chance to load - make sure that any script calls you have inside your partial view will only run once the page has loaded, and not immediately during loading.
All the above cases are ok.But sometimes developer forget to add javascript files for ajax .So please check that also.
Basically you might be missing: MicrosoftMvcAjax., MicrosoftMvcValidation.debug and MicrosoftMvcValidation JS file references.
Do the below steps:
PM> Install-Package MicrosoftAjax
PM> Install-Package MicrosoftMvcAjax.Mvc5
Include them in bundleconfig like below:
bundles.Add(new ScriptBundle("~/bundles/mvcFoolProof")
.Include("~/Scripts/MicrosoftAjax*",
"~/Scripts/MicrosoftMvcAjax*",
"~/Scripts/MicrosoftMvcValidation*",
"~/Scripts/mvcfoolproof*",
"~/Scripts/MvcFoolproofJQueryValidation*",
"~/Scripts/MvcFoolproofValidation*"));
Now it should work without any errors.
Add to web.cofig in section:
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Regarding your response to Sam, one thing I've noticed in a lot of MVC apps is that people don't know how to deal with the ambiguity of relative paths and the application/runtime. For example, the URL rewriting pretty much guarantees that a particular page can appear at different depths than you anticipated, so ../../images will point somewhere else depending on whether you're looking at /products/widget or /products/widget/12345, even though the view might be the same. As Arty pointed out, the best way to deal with this is to let the engine do the work for you by using a URL utility and application-relative paths that will be fixed up by the application regardless of the context.
I have also found that using the following works with ASP.NET MVC2.
Instead of using MicrosoftMvcAjax.js, you use MicrosoftMvcValidation.js
Hope this helps someone.

Registering User Controls in web.config Shows Error, But Controls Work Anyway

This has been bugging me all morning and I can't even figure out where the error is.
In the current web site I am developing (it's not a web application, in case it makes a difference, there are user controls declared as follows:
<controls>
<add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~\controls\TransitLinkAdmin.ascx"/>
<add tagPrefix="uc1" tagName="TransitLinkList" src="~\controls\TransitLinkList.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageAdmin" src="~\controls\WelcomeMessageAdmin.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageDisplay" src="~\controls\WelcomeMessageDisplay.ascx"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
So far so good, right?
But when I try to add one of these controls to a page, I get an error telling me that the control cannot be found. So why when I run the page, I can use the control?
The designer is telling me that it cannot find the user control file and it is using the path from the web.config file, so it must be looking at it in some fashion.
If I register the control directly in the page, no problems there.
My assumption (and we now how that works) is that there is some compilation error for the site as a whole that is preventing the intellisense from working.
Thanks in advance, all.
Just a complete guess, but maybe it is because you are using backslashes instead of forward slashes? Try:
<add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~/controls/TransitLinkAdmin.ascx"/>
<add tagPrefix="uc1" tagName="TransitLinkList" src="~/controls/TransitLinkList.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageAdmin" src="~/controls/WelcomeMessageAdmin.ascx"/>
<add tagPrefix="uc1" tagName="WelcomeMessageDisplay" src="~/controls/WelcomeMessageDisplay.ascx"/>
Are you using resharper?
I am not sure what version, but somewhere along the way this artifact had happened.
try updating to the last version.
btw they have an early access program where you can download builds (decent quality), and be updatd with the latest features and fixes.
link to early access program
Close visual studio
Move to the location:
In Windows 7:
C:\Users\Pavel\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas
In Windows XP:
C:\Documents and Settings[your username]\Application Data\Microsoft\VisualStudio\10.0\ReflectedSchemas in windows XP
Delete all the files in that folder location. Note that it is completely safe to delete files in this location.
Then reopen visual studio.
This should solve your problem.

Resources