我想創建這樣的app_code文件夾下一個asp.net MVC 3剃鬚刀幫手的定義:system.web.mvc.htmlhelper不包含的內容
@using System.Web.Mvc;
@helper Script(string scriptName, System.Web.Mvc.HtmlHelper url){
<script src="@url.Content"~/Scripts/" + scriptName)" type="text/javascript"></script>
}
,但我得到錯誤:
system.web.mvc.htmlhelper不包含的內容
的定義在以下行:
<script src="@url.Content"~/Scripts/" + scriptName)" type="text/javascript"></script>
嗨:感謝您的回覆。但是我發佈的代碼有什麼問題。它來自於asp.net MVC 3網站上的視頻http://www.pluralsight-training.net/microsoft/players/PSODPlayer?author=scott-allen&name=mvc3-building-ajax&mode=live&clip=0&course=aspdotnet-mvc3-intro – DotnetSparrow
我更新了我的答案,也許這可以幫助你...我現在看看視頻 – dknaack
你可以在一個視圖內以你想要的方式做到這一點。如果你想從其他視圖訪問,你應該在我的答案中寫一個真正的HtmlHelper。 – dknaack