Deb
Deb

Reputation: 991

Calling Server side Methods in MVC2 view

I have a view which includes

<link href="<%=ScriptUrl.ToUrl("~/Content/App_Themes/Blue/Sales_Blue.css")%>"
    rel="stylesheet" type="text/css" />

in the head section of the view

I have a class as follow which is referenced in the concerned controller :

namespace MVCTEMP.HtmlHelpers
.....
    public class ScriptUrl
    {
        public static string ToUrl(string path)
        {
            return string.Format("{0}?v={1}", VirtualPathUtility.ToAbsolute(path), MvcApplication.Version);
        }
    }

Why do i get The name 'ScriptUrl' does not exist in the current context when i hit run ?

any help will be appreciated thanks deb

Upvotes: 0

Views: 95

Answers (1)

Ajeesh M
Ajeesh M

Reputation: 2092

Your view should be

<link href="<%=MVCTEMP.HtmlHelpers.ScriptUrl.ToUrl("~/Content/App_Themes/Blue/Sales_Blue.css")%>" rel="stylesheet" type="text/css" />

Upvotes: 1

Related Questions