selected menu item in mvc3 - asp.net-mvc-3

I am creating my first mvc3 application (no previous mvc either) I am wanting to create a top level menu and be able to add a "selected" or "active" css class to the select LI tag. I found this link active menu item - asp.net mvc3 master page Ihave tried to add it to a class however I get an error back "Error 1 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'ActionLink' and no extension method 'ActionLink' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?) G:\MvcMusicStore-v2.0\MvcMusicStore-Completed\MvcMusicStore\Helpers\HtmlHelpers.cs 26 31 MvcMusicStore
"
So I am thinking I am missing a reference to something however I don't know what. Can someone kindly tell me what I need to reference to get this to work.

Add the following using at the top of your HtmlHelpers.cs file:
using System.Web.Mvc.Html;
Now the htmlHelper.ActionLink line should compile just fine.

Related

Use Umbraco .NET Custom Control

I want to use Umbraco .NET Custom Control in Macro.
I have gone through following steps:
1) I have created new Macro with name TestProperty
2) Browse and Add Pramater from Assembly
3) Use Macro in Template
I did not get any problem till last step. But when i am previewing my Content then I am getting Page with Error as Below:
How can I get my Property Value in this case?
TestProperty is an Int. Try
new {TestProperty=2}
See http://blog.darren-ferguson.com/2014/05/13/typed-access-to-umbraco-marco-parameters-in-partial-views/

How to restore working solution?

I was working on a C# project and everything works perfectly fine. But after I messed up with a code a little now its getting a wired error. But I can run the last working solution fine. Can I reset the code again to last working solution? If I can, what is the method to do that?
Here is the error message:
"Error 1 'Static_calc.Form2' does not contain a definition for
'Form2_Load' and no extension method 'Form2_Load' accepting a first
argument of type 'Static_calc.Form2' could be found (are you missing a
using directive or an assembly reference?)"
That sounds like you have deleted a method that your form is rely on in its designer code behind. Take a look in the designer file for Form2 for any event bindings that relate to Form2_Load and delete the line that mentions it.
You should then be able to view the form correctly in the gui and use it as before.

Fail to load assembly on a MVC View

Some Context
I have one closed source asp.net MVC application distributed for several customers. I'm trying to develop a extension to include some very specific functionalities that will be used by a single customer (he will also have the extension source code).
I'm developing the extension as another mvc project, loaded as an area. I'm trying to avoid having to deploy the extension binaries in the main application '/bin' folder.
I'm loading the extension assembly and it's dependencies manually in the PreApplicationStartMethod of the main application assembly. The area registration process went fine and the area routes are registered as intended.
The Problem
When I try to load some extension pages, I got a "The view 'xx' or its master was not found or no view engine supports the searched locations." message. I investigated I little and replaced the view contents with a 'Hello' string. The view was rendered correctly.
I tried to produce a minimal that triggers the error and turns out it's the '#model'directive. I tried to figure out what's happening and It's an assembly loading error. I created a minimal view with '#model object' and tried to cast the Model to original type and got the following error message: "Could not load file or assembly 'xxx' or one of its dependencies. The system cannot find the file specified." (this assembly contains the class type used by the view)
Just to confirm the issue, I moved the mentioned assembly to the main application '/bin' folder and everything worked.
I also inserted some model manipulation instructions on the controller, just to investigate if an exception will appear but everything went fine, I could even render a grid using json.
I'm loading every assemly with:
var assembly = Assembly.LoadFrom(file)
BuildManager.AddReferencedAssembly(assembly)
There's something extra I need to do ?
Needed to add the assembly private path
AppDomain.CurrentDomain.AppendPrivatePath(pluginFolder);
Don't know the real explanation for it but I guess it's relates to the use of Assembly.LoadFrom(file) instead of Assembly.Load() and the fact that views are compiled later.

Error Partial xaml WP7

I get this error, I try to copy my old project to another with modifing the name of namspace
The error indicates that you have another file with a partial definition of this same class that shares a different base class. Find this other partial definition and resolve.

Add a Custom Control reference in VS10

I recently created my first custom control. I attempted to add it in a separate project I have constructed.
I recieve this error:
The type 'System.Windows.Controls.Control' is defined in an assembly that is not referenced. You must add a reference to assembly
Here are the steps I took to add the control.
Add the Custom Control as a Reference in project
Add the attribute xmlns:MyNamespace="clr-namespace:CustomControls;assembly=CustomControls" to the root element of the markup file where it is being used
Rebuild the Controller and the project
You also need a reference to PresentationFramework.dll

Resources