English 中文(简体)
在Razak ASP使用“@helpers from another View”。 Net MVC3
原标题:Using @helpers from another View in Razor ASP.Net MVC3

I want to write a few simple @helpers to use in several views. I want them to be inside a Razor .cshtml file (not in a c# class) to have the HTML syntax highlighted.

我可以很容易地查阅同文中书写的@helpers。 我认为,我可以将其分为<代码>Helpers.cshtml,如果我把这一条码放在“Helpers.cshtml@Helpers.MyHelper()从中获取。 但是,我只希望能用几页时间查阅这些文件。

我认为,如果帮助者身为一等,那么它就好像是一种“用”,而只是另一种看法的“名称空间”是什么。

最佳回答

Sorry, but that s not possible with helpers Deposit in the App_Code/code> rafter as .cshtml file. 这些意见将在所有意见中分享。

问题回答

暂无回答




相关问题
How to update shared view adminheader.cshtml from a model

I ve added a drop down into my shared adminheader.cshtl view and it needs to be dynamically updated from data from a table. So when I use another view like routeplan.cshtml I load the view from ...

ASP.NET MVC Razor view engine

After reading Scott Guthrie s blog entry about the new Razor view engine for ASP.NET MVC and reading this question comparing the available view engines. Razor seems to address most of the problems ...

Client Id for Property (ASP.Net MVC)

I m trying to do a label for a TextBox in my View and I d like to know, how can I take a Id that will be render in client to generate scripts... for example: <label for="<%=x.Name.ClientId%>"...

Get Current Area Name in View or Controller

How do you get the current area name in the view or controller? Is there anything like ViewContext.RouteData.Values["controller"] for areas?

MVC which submit button has been pressed

I have two buttons on my MVC form: <input name="submit" type="submit" id="submit" value="Save" /> <input name="process" type="submit" id="process" value="Process" /> From my Controller ...