我的擴展沒有在我的vbhtml視圖中導入。我似乎在某處失去了一些東西..任何人都可以幫忙嗎?未導入視圖的.NET MVC3 Razor(VB!)擴展?
的module.vb:
Imports System.Runtime.CompilerServices
Namespace Areas.Admin.Models.Extensions
<Extension()> _
Public Module InputExtensions
Public Function SelectHumanGroup(ByVal helper As HtmlHelper, ByVal name As String, Optional ByVal selectedValue As String = "", Optional ByVal htmlAttributes As Object = Nothing) As MvcHtmlString
Return helper.DropDownList(name, repo.GetGroups(), htmlAttributes)
End Function
End Module
End Namespace
的view.vbhtml:
@Imports MySite.Areas.Admin.Models.Extensions
@ModelType MySite.Models.MyViewModel
@Code
ViewData("Title") = "Index"
End Code
<h2>Index</h2>
@Html.SelectHumanGroup("test")
這是行不通的。引發同樣的錯誤:'SelectUserGroup'不是'System.Web.Mvc.HtmlHelper'的成員。 – Ropstah 2011-01-25 02:15:13
對不起,錯誤是:'SelectUserGroup'不是'System.Web.Mvc.HtmlHelper(Of MySite.Models.MyViewModel)'的成員。 MyViewModel被傳遞給視圖,並在視圖中也被引用(我更新了問題..) – Ropstah 2011-01-25 02:16:02