如何在.cshtml中访问类 [英] How can I access to class in .cshtml
本文介绍了如何在.cshtml中访问类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为Service的类,并且有一个函数。我想访问actionlink中的功能
I have got a class as Service named and there is a function. I want to access to function in actionlink
public class Service
{
public string SpecialChar(string text)
{
//Some Magic
return Magic;
}
}
.cshtml:
.cshtml:
@Html.ActionLink(building.BuildingName, "BuildingDetail", new {uniname= building.University.UniName, buildingname = building.BuildingName, id =building.BuildingID})
i寻找这样的代码
i looking for code like this
...new{Service.SpecialChar(building.University.Uniname)...
我尝试过:
我还没找到可能正常工作的代码
What I have tried:
I haven't can find code probably work
推荐答案
试试这个< br $>
try like this
public class MyClass
{
public static string GetSomeValue(string arg)
{
return arg;
}
}
@Html.ActionLink("test", "actionname", new { arg1= MyClass.GetSomeValue("some") })
这篇关于如何在.cshtml中访问类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文