0

I have an MVC app. I created a resources folder with resources files in it.

In my view I can type:

InvoiceStatuses.Received

which is the equivalent to "received" so avoiding the magic string.

However in my view I currently have something like:

@if (item.Status == "received")

I can't seem to use the resource in the view for some reason. I type it but it doesn't recognise it. I guess this is because in the view there is no where to put a:

using MyApp.Resources;

Can someone please tell me if it is possible to use this resource in the view and if so how?

1 Answer 1

2

To add using to the view use the following syntax

@using MyNamespace

Once you add the namespace reference you can access any class members that are part of this namespace.
I believe you can also achieve the same by typing the complete class name and use the shortcut key Ctrl + . to resolve the reference.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.