Tag: asp.net mvc helpers

MVcHtmlString中的堆栈溢出exception

我创建了自己的Html Helper,它可以为任何必填字段添加红色星号。 它成功地适用于两者 @Html.myLabelFor(model => model.Description) //and @Html.myLabelFor(model => model.Description, new { /*stuff*/ }) 但是,一些代码行如下所示 @Html.myLabelFor(model => model.Description, “Deletion Reason”, new { /*stuff*/ }) 我的方法不是为处理3个参数而设计的,所以我添加了一个可以处理3个参数的调用者 public static MvcHtmlString myLabelFor(this HtmlHelper html, Expression<Func> expression, string labelText, Object htmlAttributes) { return myLabelFor(html, expression, labelText, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)); } 下面是其他正常工作的方法(包括内部,包含所有必要的代码,我的结构用作参考) public static MvcHtmlString myLabelFor(this HtmlHelper html, Expression<Func> expression, IDictionary htmlAttributes) […]