public static ModelMetadataItemBuilder <TModel> RenderAction <TModel>([NotNull] this ModelMetadataItemBuilder <TModel> self, Func <HtmlHelper, IHtmlString> action) { self.Template("RenderAction"); var settings = self.Item.GetAdditionalSettingOrCreateNew <RenderActionSetting>(); settings.Action = action; return(self); }
/// <summary> /// Indicates that the value would appear as url in display mode. /// </summary> /// <param name="self"></param> /// <returns></returns> public static ModelMetadataItemBuilder <string> AsUrl(this ModelMetadataItemBuilder <string> self) { self.Template("Url"); if (self.Item.GetValidation <RegularExpressionValidationMetadata>() != null) { throw new InvalidOperationException(ExceptionMessages.CannotApplyUrlWhenThereIsAnActiveExpression); } return(Expression(self, UrlExpression, ((UrlErrorMessageResourceType == null) && string.IsNullOrEmpty(UrlErrorMessageResourceName)) ? () => UrlErrorMessage : (Func <string>)null, UrlErrorMessageResourceType, UrlErrorMessageResourceName)); }
public static ModelMetadataItemBuilder <string> AsEmail([NotNull] this ModelMetadataItemBuilder <string> self) { self.Template("EmailAddress"); self.AddAction( m => { if (m.GetValidation <RegularExpressionValidationMetadata>() != null) { throw new InvalidOperationException(ExceptionMessages.CannotApplyEmailWhenThereIsAnActiveExpression); } }); return(Expression(self, EmailExpression, ((EmailErrorMessageResourceType == null) && string.IsNullOrEmpty(EmailErrorMessageResourceName)) ? () => EmailErrorMessage : (Func <string>)null, EmailErrorMessageResourceType, EmailErrorMessageResourceName)); }
/// <summary> /// Marks the value to render as password element in edit mode. /// </summary> /// <param name="self"></param> /// <returns></returns> public static ModelMetadataItemBuilder <string> AsPassword(this ModelMetadataItemBuilder <string> self) { return(self.Template("Password")); }
/// <summary> /// Marks the value to render as text area element in edit mode. /// </summary> /// <param name="self"></param> /// <returns></returns> public static ModelMetadataItemBuilder <string> AsMultilineText(this ModelMetadataItemBuilder <string> self) { return(self.Template("MultilineText")); }
/// <summary> /// Indicates that the value would appear as raw html in display mode, so no encoding will be performed. /// </summary> /// <param name="self"></param> /// <returns></returns> public static ModelMetadataItemBuilder <string> AsHtml(this ModelMetadataItemBuilder <string> self) { return(self.Template("Html")); }