private static string GetTextField(this HtmlHelper html, PropertyContext propertyContext, string id, string tooltip, bool readOnly) { var tag = new TagBuilder("div"); tag.AddCssClass(IdConstants.ValueName); var htmlAttributes = new RouteValueDictionary(new { title = tooltip }); html.AddClientValidationAttributes(propertyContext, htmlAttributes); if (!propertyContext.Property.IsVisible(propertyContext.Target)) { tag.InnerHtml += html.Encrypted(id, html.GetRawValue(propertyContext)).ToString(); propertyContext.IsPropertyEdit = false; } else if (propertyContext.Property.Specification.IsBoolean && !readOnly) { var state = propertyContext.Property.GetValue(propertyContext.Target).GetDomainObject<bool?>(); if (propertyContext.Property.IsNullable) { html.AddTriState(tag, htmlAttributes, id, state); } else { html.AddCheckBox(tag, htmlAttributes, id, state); } } else if (propertyContext.Property.Specification.IsDateTime && !readOnly) { html.AddDateTimeControl(tag, htmlAttributes, propertyContext, id, html.GetPropertyValue(propertyContext)); } else if (propertyContext.Property.IsPassword && !readOnly) { html.AddPasswordControl(tag, htmlAttributes, propertyContext, id, html.GetPropertyValue(propertyContext)); } else if (propertyContext.Property.IsChoicesEnabled != Choices.NotEnabled && !readOnly) { html.AddDropDownControl(tag, htmlAttributes, propertyContext, id); } else if (propertyContext.Property.IsAutoCompleteEnabled && !readOnly) { html.AddAutoCompleteControl(tag, htmlAttributes, propertyContext, propertyContext.Property.GetValue(propertyContext.Target)); } else { string rawValue = html.GetRawValue(propertyContext); if (readOnly) { tag.InnerHtml += html.GetFieldValue(propertyContext) + html.CustomEncrypted(id, rawValue); propertyContext.IsPropertyEdit = false; } else { html.AddTextControl(tag, htmlAttributes, propertyContext, id, html.ZeroValueIfTransientAndNotSet(propertyContext, rawValue)); } } return tag.ToString(); }
private static string GetTextParameter(this HtmlHelper html, ParameterContext context, string id, string tooltip) { var tag = new TagBuilder("div"); tag.AddCssClass(IdConstants.ValueName); var htmlAttributes = new RouteValueDictionary(new { title = tooltip }); html.AddClientValidationAttributes(context, htmlAttributes); if (context.IsHidden) { object obj = html.ViewData[id]; tag.InnerHtml += html.Encrypted(id, obj.ToString()); } else if (context.Parameter.Specification.IsBoolean) { if (context.Parameter.IsNullable) { html.AddTriState(tag, htmlAttributes, id, null); } else { html.AddCheckBox(tag, htmlAttributes, id, null); } } else if (context.Parameter.Specification.IsDateTime) { html.AddDateTimeControl(tag, htmlAttributes, context, id, html.GetFieldValue(context, id)); } else if (context.Parameter.IsPassword) { html.AddPasswordControl(tag, htmlAttributes, context, id, html.GetFieldValue(context, id)); } else if (context.Parameter.IsChoicesEnabled == Choices.Single) { html.AddDropDownControl(tag, htmlAttributes, context, id); } else if (context.Parameter.IsChoicesEnabled == Choices.Multiple) { html.AddListBoxControl(tag, htmlAttributes, context, id); } else if (context.Parameter.IsAutoCompleteEnabled) { html.AddAutoCompleteControl(tag, htmlAttributes, context, html.GetParameterDefaultValue(id, context)); } else { html.AddTextControl(tag, htmlAttributes, context, id, null); } return tag.ToString(); }