0
所以我在這裏創建這個方法並使其工作時有很多幫助......但是因爲這是一個不同的人,所以我想我會提出另一個問題。將數組傳遞給擴展HTML Helper時出錯
首先,我有一個HTML Helper擴展方法,它通過傳遞額外的字符串來確定我在擴展中檢查的權限。我現在想在字符串(權限)的數組來傳遞,並通過他們的方法循環,但我得到這個錯誤:
CS1501:沒有重載方法「CheckBoxForWithPermission」需要4個參數
這裏是助手的電話:
<%= Html.CheckBoxForWithPermission(m => m.Current, new string[] { Chatham.Web.Business.Definitions.Constants.PERMISSIONS.hasICAdvanced }, Chatham.Web.Business.Definitions.Constants.PERMISSIONS.hasICAdvanced, new { @class = "economicTextBox", propertyName = "Current", onchange = "UseCurrent();UpdateField(this);" })%>
,這裏是實際的方法:
// CHECKBOX WITH PERMISSIONS
// WITHOUT -- READONLY
public static MvcHtmlString CheckBoxForWithPermission<TModel>(
this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, bool>> expression,
string[] permissions,
object htmlAttributes
)
{
foreach (string permission in permissions)
{
if (Chatham.Web.UI.Extranet.SessionManager.PhysicalUser.IsInRole(permission))
{
// the user has the permission => render the checkbox
return htmlHelper.CheckBoxFor(expression, htmlAttributes);
}
}
// the user has no permission => render a readonly checkbox
var mergedHtmlAttributes = new RouteValueDictionary(htmlAttributes);
mergedHtmlAttributes["disabled"] = "disabled";
return htmlHelper.CheckBoxFor(expression, mergedHtmlAttributes);
}
我這樣一個白癡。今天我的頭不在遊戲中。謝謝。 – slandau 2011-01-13 19:55:28