我在ASP.NET MVC 5中创建了一个自定义帮助程序。以下是代码:
Razor语法:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.clearColor()], forState: UIControlState.Normal)
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.clearColor()], forState: UIControlState.Highlighted)
return true
}
应用帮助:
@ListCountries(ViewBag.Countries,ViewBag.Selected)
这是我控制器中的代码:
@helper ListCountries(string[] items, string selected)
{
<div class="form-group">
<select class="form-control">
@foreach (string str in items)
{
if (@str == selected)
{
<option selected="selected">@str</option>
}
else
{
<option>@str</option>
}
}
</select>
</div>
}
我需要的是,我想将上面给出的帮助声明(Razor语法)存储在像.js或.css文件这样的公共位置,以便可以从任何页面引用它。有什么想法吗?