public static IHtmlContent RPCSAutocompleteDropDownList <TModel, TProperty1, TProperty2>( this IHtmlHelper <TModel> html, Expression <Func <TModel, TProperty1> > expression, Expression <Func <TModel, TProperty2> > displayExpression, IEnumerable <SelectListItem> selectList, string optionLabel, OperationSet editRights, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); var label = HtmlHelperLabelExtensions.LabelFor(html, expression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(editRights)) { string controlName = GetExpressionParam <TModel, TProperty1>(expression); string initScript = string.Format("<script>$(document).ready(function () {{ $('#{0}').combobox(); }});</script>", controlName); var contents = html.DropDownListFor(expression, selectList, optionLabel, new { @class = "form-control" }); string result = String.Concat( GetString(contents), initScript ); return(new HtmlString(result)); } string l = GetString(html.HiddenFor(expression)); if (appUserSvc.HasAccess(displayRights)) { var contents = html.DisplayFor(displayExpression); string result = GetString(contents); return(new HtmlString(result + l)); } return(new HtmlString(l)); }
public static IHtmlContent PassWordFormGroupInputFor <TModel, TValue>( this IHtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TValue> > property, string placeholder, object labelAttributes = null, object textBoxAttributes = null, bool localValidation = true) { using (var writer = new StringWriter()) { writer.Write("<div class='form-group'>"); HtmlHelperLabelExtensions.LabelFor( htmlHelper, property, labelAttributes) .WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); HtmlHelperInputExtensions.TextBoxFor( htmlHelper, property, textBoxAttributes ?? new { placeholder, @class = "form-control", @type = "password" }) .WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); if (localValidation) { HtmlHelperValidationExtensions.ValidationMessageFor( htmlHelper, property) .WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default); } writer.Write("</div>"); return(new HtmlString(writer.ToString())); } }
public static IHtmlContent RPCSDisplayWithItemDetailsViewActionForEmployee <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, int employeeId, OperationSet displayRights, string itemController, object itemRouteValues, OperationSet viewItemDetailsRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); bool hasAccess = appUserSvc.HasAccess(displayRights); if (displayRights.Contains(Operation.EmployeePersonalDataView) && appUserSvc.HasAccess(Operation.EmployeeSubEmplPersonalDataView)) { hasAccess = hasAccess || appUserSvc.IsDepartmentManagerForEmployee(employeeId); } if (displayRights.Contains(Operation.EmployeePersonalDataView) && appUserSvc.GetEmployeeID() == employeeId) { hasAccess = true; } if (hasAccess) { IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" }); IHtmlContent contents = null; var value = ExpressionMetadataProvider.FromLambdaExpression(valueExpression, html.ViewData, html.MetadataProvider).Model; if (appUserSvc.HasAccess(viewItemDetailsRights) && value != null && String.IsNullOrEmpty(value.ToString()) == false) { var urlHelper = _serviceProvider.GetRequiredService <IUrlHelper>(); string linkText = value.ToString(); var anchor = new TagBuilder("a"); anchor.InnerHtml.Append(string.IsNullOrEmpty(linkText) ? "No Name" : linkText); anchor.Attributes["href"] = urlHelper.Action("Details", itemController, itemRouteValues); anchor.Attributes["target"] = "_blank"; contents = new HtmlString(GetString(anchor)); } else { contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression); } string result = String.Concat("<div class=\"row\">", GetString(label), "<div class=\"col-md-8\" style=\"padding:6px 12px\" >", GetString(contents), "</div>", "</div>"); return(new HtmlString(result)); } return(new HtmlString("")); // html.HiddenFor(expression); }
private static IHtmlContent LabelEditor <TModel, TValue>(IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression) { var editor = HtmlHelperLabelExtensions.LabelFor(html, expression); var value = html.ValueFor(expression); if (value.ToString() == "") { return(new HtmlString("<label></label>")); } else { return(editor); } }
public static IHtmlContent RPCSAutocompleteDropDownList <TModel, TValue1>( this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression) { var label = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" }); var dropDown = GenerateDropDown(html, labelExpression); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\">", GetString(dropDown), "</div>", "</div>"); return(new HtmlString(result)); }
public static IHtmlContent RPCSEditorFor <TModel, TValue>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, OperationSet EditorRights, OperationSet displayRights, string toolTip = "", string errorMessage = "") { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, expression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(EditorRights)) { return(GenerateEditor(html, expression, toolTip, errorMessage, label)); } if (appUserSvc.HasAccess(displayRights)) { return(GenerateLabel(html, expression, label)); } return(HtmlHelperInputExtensions.HiddenFor(html, expression)); }
public static IHtmlContent RPCSDropDownList <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, string name, IEnumerable <SelectListItem> selectList, OperationSet editRights, OperationSet displayRights) { var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>(); IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" }); if (appUserSvc.HasAccess(editRights)) { var contents = HtmlHelperSelectExtensions.DropDownList(html, name, selectList, new { @class = "form-control" }); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\">", GetString(contents), "</div>", "</div>"); return(new HtmlString(result)); } if (appUserSvc.HasAccess(displayRights)) { IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression); string result = String.Concat("<div class=\"form-group\">", GetString(label), "<div class=\"col-md-8\">", GetString(contents), "</div>", GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression)), GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression)), "</div>"); return(new HtmlString(result)); } string v = GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression)); string l = GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression)); return(new HtmlString(v + l)); }
public static IHtmlContent DisplayNameFor <TModel, TValue>(this HtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression) { return(HtmlHelperLabelExtensions.LabelFor(html, expression)); }