We want to use Html.RenderAction in our MVC1.0 project. I have downloaded the Futures Microsoft.Web.Mvc dll from codeplex, copied it to the bin folder in our project, and added a reference to it.
However, when I try to use it in one of our views, Html.RenderAction is still not available.
It might be just a silly detail I'm missing, but I have no idea what else I have to do :(
P.S. I checked, and I can actually write "Microsoft.Web.Mvc.ViewExtensions.RenderAction" and Visual Studio autocompletes the code just fine, so it seems the dll is correctly included in the project.
You have to add it to the "namespaces" tag in web.config.
<system.web>
<pages>
<namespaces>
<add namespace="Microsoft.Web.Mvc"/>
</namespaces>
</pages>
</system.web>
RenderAction is part of the MvcFutures project.
Kindness,
Dan
You might need to modify your web.config:
<compilation debug="true">
<assemblies>
<add assembly="Microsoft.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</assemblies>
</compilation>
<pages>
<namespaces>
<add namespace="Microsoft.Web.Mvc"/>
</namespaces>
</pages>
Related
Currently I am working on a ASP.NET web form project which is using Telerik Ajax Version 2015.2.623.45, I have added Telerik.Web.UI.dll, Telerik.Web.Design.dll into my project reference, but it keeps giving me errors saying
The type or namespace name 'Telerik' could not be found in the global namespace (are you missing an assembly reference?)
Here's some info of my project if that may helps:
I am using .NET Framework 4, using Integrated Mode,
the dll's Aliases property is "global", and Copy Local property is True
and my web.config contains following parts:
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/>
</controls>
...
...
<httpHandlers>
<add verb="*" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResourceSession, Telerik.Web.UI" validate="false"/>
<add verb="*" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI" validate="false"/>
<add verb="*" path="Telerik.Web.UI.DialogHandler.axd" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI" validate="false"/>
<add verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" validate="false"/>
</httpHandlers>
...
...
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Telerik.Web.UI.RadTextBox, Telerik.Web.UI, Version=2015.2.623.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
<add assembly="Telerik.Web.UI.RadAsyncUpload, Telerik.Web.UI, Version=2015.2.623.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
<add assembly="Telerik.Web.UI.RadAjaxManagerProxy, Telerik.Web.UI, Version=2015.2.623.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
<add assembly="Telerik.Web.UI.RadCodeBlock, Telerik.Web.UI, Version=2015.2.623.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
...
...
</assemblies>
</compilation>
...
...
<handlers>
<remove name="Telerik_Web_UI_WebResource_axd"/>
<remove name="Telerik_Web_UI_SpellCheckHandler_axd"/>
<remove name="Telerik_Web_UI_DialogHandler_aspx"/>
<remove name="Telerik_RadUploadProgressHandler_ashx"/>
<add name="Telerik.Web.UI.WebResource.axd" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResourceSession, Telerik.Web.UI" preCondition="integratedMode"/>
<add name="Telerik.Web.UI.SpellCheckHandler.axd" path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI" preCondition="integratedMode"/>
<add name="Telerik.Web.UI.DialogHandler.axd" path="Telerik.Web.UI.DialogHandler.axd" verb="*" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI" preCondition="integratedMode"/>
<add name="Telerik.RadUploadProgressHandler.ashx" path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" preCondition="integratedMode"/>
</handlers>
I have Googled a lot and tried all method on Telerik Forum, but it does not help...Can someone help me and tell me what am I missing, and how can I reference Telerik.*.dll correctly?
You can try removing the references and adding them again. In the properties of the references, "Copy Local" should be set to true (but I think this is the default). Also, make sure you're adding them to the correct project in your solution! (This tripped me up once.)
Finally, make sure the DLLs you are referencing are built against the same version of the .NET Framework your project is targeting. If they're not, you'll get something like the following warning when building:
Warning 1576 The primary reference "Telerik.Web.Design, Version=2014.2.724.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".
Another way is to simply add the missing the references, this might give you an indication of missing dll files missing dlls. Your telerik dlls should be under C:\ Programe Files(x86)\Progress
Did you try to use the Telerik ASP.NET AJAX VS Extensions. To convert your project using the Telerik ASP.NET AJAX VS Extensions follow these steps:
Select your web site project in Visual Studio Solution Explorer.
In the Visual Studio menu select Telerik -> UI for ASP.NET AJAX -> Convert to Telerik Web Site
Use the configuration wizard to convert your web site. You can find more information about Configure wizard options in our documentation at http://docs.telerik.com/devtools/aspnet-ajax/general-information/integration-with-visual-studio/visual-studio-extensions/creation-and-configuration-wizard.
If you still prefer to manually manage the Telerik resources in you project you can take a look at http://docs.telerik.com/devtools/aspnet-ajax/general-information/adding-the-telerik-controls-to-your-project.
first of all check your target Framework of your current project
then check your assembly version of telerik control in 2 part : one in toolbox panel and the other one in project reference section,
all of them must be the same.
for detail of version assembly and Framework check out the link :
https://docs.telerik.com/devtools/aspnet-ajax/installation/included-assemblies
I have googled so much about this issue. I have Visual Studio 2013. Following instructions: right click in toolbox, add mediaplayer from COM components and still this error:
Element 'MediaPlayer' is not a known element. This can occur if there is a compilation error in the Website, or the web.config file is missing.
config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5"/>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
</configuration>
There is no error in website, I have the latest Silverlight. Please can someone help?
All that is needed is the System.Web.Silverlight.dll. file adding. Instructions:
1.Right click on toolbox (anywhere)
2.Select choose item
3.When the window opens click browse and search for your dll file.
What is the advantage of adding namespace in web.config file?
<configuration>
<system.web>
<pages>
<namespaces>
<add namespace="System.Collections" />
</namespaces>
</pages>
</system.web>
</configuration>
This will allow to add the namespaces of the items you commonly use in your views so you don't need to add the references in each page / view when you need to use them.
Namespaces you define here are automatically imported into all pages of an application.
I am using VS 2008 and C# but when I added namespace in web.config file, that namespace is not imported or included in code behind or aspx
I have also read this question but not get the required answer.
web.config code
<configuration>
<system.web>
<pages>
<namespaces>
<add namespace="System.Data" />
<add namespace="System.Text"/>
</namespaces>
</pages>
</system.web>
</configuration>
You need to put them in the correct <system.web> section. e.g.:
<configuration>
<system.web>
<pages>
<namespaces>
<add namespace="System.Data" />
<add namespace="System.Text"/>
</namespaces>
</pages>
</system.web>
</configuration>
and put them in the correct web.config
i.e. the second web.config file is the Views folder and is specific to views. These settings do not go in the root web.config.
The purpose of these settings is to make the libraries available to the ASPX pages (e.g. for Intellisense) and it is not used for the code-behind. You still need to have using statements in your actual code as that is just plain c# programming.
The purpose of the namespace section is to get around having to do the import in the .aspx page. Code behind in C# still requires you to have the using statements at the top of your .cs file.
There is no way to get around this.
I have a shared project where I store all of my custom EditTemplates and DisplayTemplates. This is a regular C# class library project with the views all tagged as embedded resources. The target framework of this project is ".Net Framework 4".
Inside the /Views/ folder I have included this web.config file so I get MVC 2 intellisense when working with the .aspx and .ascx files:
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
Normally I have no problems with this setup but once and while I get an error when I compile my views:
Error 3 Feature 'anonymous types'
cannot be used because it is not part
of the ISO-2 C# language
specification
for a template that looks like:
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%# Import Namespace="System.Web.Mvc.Html" %>
<%
string displayText = string.Empty;
if (Model != null)
{
if (DateTime.Parse(Model.ToString()) != DateTime.MinValue)
displayText = DateTime.Parse(Model.ToString()).ToShortDateString();
}
%>
<%= Html.TextBox("", displayText, new { #class = "date-box" })%>
Most of the time this error just goes away. I've learned to deal with it but right now its causing some issues. Any idea of what causes the "Error 3 Feature 'anonymous types' cannot be used because it is not part of the ISO-2 C# language specification" error and how I can fix this?
I've faced with this issue, and have spent a lot of time, while figured out that App.Config file with empty configuration section in it was root of the evil. Simply remove App.Config, and all will work fine.
Somehow your IDE experience is causing the 4.0 C# compiler to be limited to features allowed in the 2.0 version of the compiler. This can be done using the langversion switch. For example
csc /langversion:ISO-2 ...
Full Documentation: http://msdn.microsoft.com/en-us/library/f4ckecs0.aspx
I'm unfamiliar with how compilation works for Asp.Net MVC but somewhere in your project system you've asked to be limited to the 2.0 framework. My first guess would be to look at the project page of the project and make sure it's not targeting 2.0.
The solution for me was to change the project type
Unload the project
Edit project
Swap the project GUID for this
ProjectTypeGuids: {E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
(This is an MVC3 project)
For me this was ultimately caused by low disk space, presenting as a hailstorm of unusual and inexplicable random build errors.