34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using System;
|
|
using System.Linq.Expressions;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using System.Web.Mvc.Html;
|
|
using System.Web.Routing;
|
|
|
|
namespace EnVisage.Code.HtmlHelpers
|
|
{
|
|
public static class HtmlExtensions
|
|
{
|
|
public static IHtmlString TextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression,
|
|
object htmlAttributes, bool disabled)
|
|
{
|
|
var attributes = new RouteValueDictionary(htmlAttributes);
|
|
if (disabled)
|
|
{
|
|
attributes["disabled"] = "disabled";
|
|
}
|
|
return htmlHelper.TextBoxFor(expression, attributes);
|
|
}
|
|
|
|
public static MvcHtmlString RadioButtonFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression,
|
|
bool value, object htmlAttributes, bool disabled)
|
|
{
|
|
var attributes = new RouteValueDictionary(htmlAttributes);
|
|
if (disabled)
|
|
{
|
|
attributes["disabled"] = "disabled";
|
|
}
|
|
return htmlHelper.RadioButtonFor(expression, value, attributes);
|
|
}
|
|
}
|
|
} |