public static MvcHtmlString ButtonForAddEditSelectItem <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TProperty> > expression, string URLAction, bool isReadOnly, object htmlAttributes = null) { TagBuilder aTag = new TagBuilder("a"); TagBuilder result = new TagBuilder("button"); var fieldName = ExpressionHelper.GetExpressionText(expression); var attrs = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (isReadOnly) { AttributeMaker.AddReadOnly(attrs); AttributeMaker.AddDisabled(attrs); } else { aTag.Attributes.Add("href", URLAction); aTag.Attributes.Add("data-origin", fieldName.Replace('.', '_')); result = aTag; } foreach (var attr in attrs) { result.Attributes.Add(attr.Key, attr.Value.ToString()); } return(MvcHtmlString.Create(result.ToString())); }
public static MvcHtmlString TextAreaReadOnlyFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TProperty> > expression, bool isReadOnly, object htmlAttributes = null) { var attrs = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (isReadOnly) { AttributeMaker.AddReadOnly(attrs); } return(helper.TextAreaFor(expression, attrs)); }
public static MvcHtmlString TextBoxForDateTime <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, DateTime> > expression, bool isReadOnly, object htmlAttributes = null) { var attrs = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (isReadOnly) { AttributeMaker.AddReadOnly(attrs); } return(helper.TextBoxFor(expression, "{0:" + CommonResources.DateTimeBinder_DateTimeFormat + "}", attrs)); }
public static MvcHtmlString DropDownListReadOnlyFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TProperty> > expression, IEnumerable <SelectListItem> selectList, bool isReadOnly, object htmlAttributes = null) { var attrs = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (isReadOnly) { AttributeMaker.AddReadOnly(attrs); AttributeMaker.AddDisabled(attrs); } return(helper.DropDownListFor(expression, selectList, attrs)); }
public static MvcHtmlString RadioButtonReadOnlyFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TProperty> > expression, bool isReadOnly, object value, object htmlAttributes = null) { var indexedAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (isReadOnly) { AttributeMaker.AddDisabled(indexedAttributes); AttributeMaker.AddReadOnly(indexedAttributes); } StringBuilder result = new StringBuilder(); var radiobutton = helper.RadioButtonFor(expression, value, indexedAttributes); result.Append(radiobutton); return(MvcHtmlString.Create(result.ToString())); }