public static MvcHtmlString ManipulationButton <VM, T>( this HtmlHelper <VM> htmlHelper, ManipulationButtonType manipulationButtonType, string textOrUrl, Expression <Func <VM, T> > target, string name = null, ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button, IDictionary <string, object> htmlAttributes = null) { if (target == null) { throw new ArgumentNullException("target"); } string targetName = BasicHtmlHelper.IdFromName(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName( ExpressionHelper.GetExpressionText(target))); return (ManipulationButton <VM>( htmlHelper, manipulationButtonType, textOrUrl, targetName, name, manipulationButtonStyle, htmlAttributes)); }
private static void getPropertiesToUpdate(StringBuilder sb, string prefix, PropertyInfo[] propertiesToUpdate, Stack <Type> recursionControl) { for (int i = 0; i < propertiesToUpdate.Length; i++) { if (i > 0) { sb.Append(','); } if (typeof(IConvertible).IsAssignableFrom(propertiesToUpdate[i].PropertyType)) { sb.Append(BasicHtmlHelper.IdFromName(BasicHtmlHelper.AddField(prefix, propertiesToUpdate[i].Name))); } else if (!typeof(System.Collections.IEnumerable).IsAssignableFrom(propertiesToUpdate[i].PropertyType)) { bool recursion = false; foreach (Type type in recursionControl) { if (type == propertiesToUpdate[i].PropertyType) { recursion = true; } } if (recursion) { continue; } recursionControl.Push(propertiesToUpdate[i].PropertyType); getPropertiesToUpdate( sb, BasicHtmlHelper.AddField(prefix, propertiesToUpdate[i].Name), BasicHtmlHelper.GetPropertiesForInput(propertiesToUpdate[i].PropertyType), recursionControl); recursionControl.Pop(); } } }
protected MvcHtmlString BaseButton(string displayName, ManipulationButtonStyle buttonStyle, IDictionary <string, object> htmlAttributes) { switch (buttonStyle) { case ManipulationButtonStyle.Button: return(MvcHtmlString.Create ( string.Format("<input type=\"button\" value=\"{0}\" {1} />", CurrHtmlHelper.Encode(displayName), BasicHtmlHelper.GetAttributesString(htmlAttributes)) )); case ManipulationButtonStyle.Image: htmlAttributes["src"] = displayName; BasicHtmlHelper.SetDefaultStyle(htmlAttributes, "cursor", "pointer"); return(MvcHtmlString.Create ( string.Format("<img {1} />", displayName, BasicHtmlHelper.GetAttributesString(htmlAttributes)) )); default: htmlAttributes["href"] = "javascript:void(0);"; return(MvcHtmlString.Create ( string.Format("<a {1}>{0}</a>", CurrHtmlHelper.Encode(displayName), BasicHtmlHelper.GetAttributesString(htmlAttributes)) )); } }
public static MvcHtmlString GenericInputFor <VM, T>( this HtmlHelper <VM> htmlHelper, InputType inputType, Expression <Func <VM, T> > expression) { if (expression == null) { throw (new ArgumentNullException("expression")); } var name = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName( ExpressionHelper.GetExpressionText(expression)); string type = GetInputTypeString(inputType); T value = default(T); try { value = expression.Compile().Invoke(htmlHelper.ViewData.Model); } catch { } return(MvcHtmlString.Create( string.Format("<input type='{3}' name='{0}' id='{1}' value='{2}' />", name, BasicHtmlHelper.IdFromName(name), htmlHelper.Encode(Convert.ToString(value, CultureInfo.InvariantCulture)), type))); }
public MvcHtmlString AvailableItems(IDictionary <string, object> htmlAttributes = null) { List <ExtendedSelectListItem> NotSelected = new List <ExtendedSelectListItem>(); foreach (ExtendedSelectListItem sel in allItems) { if (!valuesSet.Contains(sel.Value)) { NotSelected.Add(sel); } } if (htmlAttributes == null) { htmlAttributes = new Dictionary <string, object>(); } htmlAttributes["data-elementispart"] = "true"; return(MvcHtmlString.Create ( CurrHtmlHelper.DropDownbase <TModel, TChoiceItem, TDisplay, TValue>( BasicHtmlHelper.AddField(Prefix, "$.PackedValue") + DualSelect_SelectAvial, new List <TValue>() as IEnumerable <TValue>, NotSelected, htmlAttributes, true, false).ToString() )); }
protected void AddFunctions(ref IDictionary <string, object> htmlAttributes, bool chosen) { if (!chosen && htmlAttributes != null && htmlAttributes.ContainsKey("role-name")) { Role = htmlAttributes["role-name"] as string; htmlAttributes.Remove("role-name"); } if (!chosen) { return; } if (functionWritten) { return; } if (htmlAttributes == null) { htmlAttributes = new Dictionary <string, object>(); } if (Role != null) { htmlAttributes["role-name"] = Role; Role = null; } string id = BasicHtmlHelper.IdFromName(BasicHtmlHelper.AddField(this.totalPrefix, "$")); htmlAttributes["mvc-controls-toolkit-set"] = string.Format("function(x) {{MvcControlsToolkit_DateTime_Set('{0}', x);}}", id); htmlAttributes["mvc-controls-toolkit-get-true"] = string.Format("MvcControlsToolkit_DateTime_GetTrue('{0}')", id); functionWritten = true; }
public MvcHtmlString SelectedItems(IDictionary <string, object> htmlAttributes = null) { List <ExtendedSelectListItem> selected = new List <ExtendedSelectListItem>(); foreach (TValue val in Value) { if (allItemsDictionary.ContainsKey(val.ToString())) { selected.Add(allItemsDictionary[val.ToString()]); } } if (htmlAttributes == null) { htmlAttributes = new Dictionary <string, object>(); } htmlAttributes["data-elementispart"] = "true"; return(MvcHtmlString.Create ( RenderPackedList() + CurrHtmlHelper.DropDownbase <TModel, TChoiceItem, TDisplay, TValue> ( BasicHtmlHelper.AddField(Prefix, "$.PackedValue") + DualSelect_SelectSelected, new List <TValue>() as IEnumerable <TValue>, selected, htmlAttributes, true, false).ToString() )); }
protected string RenderPackedList() { PackedList <IEnumerable <TValue>, TValue> displayModel = new PackedList <IEnumerable <TValue>, TValue>(); displayModel.ImportFromModel(Value, new object[] { DualSelect_Separator }); StringBuilder sb = new StringBuilder(); sb.Append(BasicHtmlHelper.RenderDisplayInfo(CurrHtmlHelper, typeof(PackedList <IEnumerable <TValue>, TValue>), Prefix)); sb.AppendFormat("<span {2} style='display:none' id='{1}' is-item-control='true' pname='{0}' data-element-type = 'DualSelect' ></span>", _fullprefix, BasicHtmlHelper.IdFromName(_fullprefix), BasicHtmlHelper.GetAttributesString(AttributeExtensions)); sb.Append( CurrHtmlHelper.Hidden(BasicHtmlHelper.AddField(Prefix, "$.Separator"), DualSelect_Separator, new RouteValueDictionary { { "data-elementispart", "true" } })).ToString(); sb.Append(CurrHtmlHelper.Hidden( BasicHtmlHelper.AddField(Prefix, "$.PackedValue"), displayModel.PackedValue, new RouteValueDictionary { { "data-elementispart", "true" } })); return(sb.ToString()); }
public static MvcHtmlString ViewsOnOff <M>(this HtmlHelper <M> htmlHelper, string groupName, bool initialOn) { if (groupName == null) { throw (new ArgumentNullException("groupName")); } string viewsOnOffScript = null; string partialName = groupName + "_selection"; string fullName = htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(partialName); string fullId = BasicHtmlHelper.IdFromName(fullName); switch (MvcEnvironment.Validation(htmlHelper)) { case ValidationType.StandardClient: viewsOnOffScript = viewsOnOfScriptStandardClient; break; case ValidationType.UnobtrusiveClient: viewsOnOffScript = viewsOnOfScriptScriptUnobtrusiveClient; break; default: viewsOnOffScript = viewsOnOfScriptScriptNoClient; break; } ValueProviderResult vr = htmlHelper.ViewContext.Controller.ValueProvider.GetValue(fullName); if (vr != null) { initialOn = (bool)(vr.ConvertTo(typeof(bool))); } return(MvcHtmlString.Create( htmlHelper.Hidden(partialName, initialOn) + string.Format(viewsOnOffScript, groupName, initialOn ? "true":"false", fullId) )); }
internal string GetChangedItem(string prefix, HtmlHelper <TModel> htmlHelper, object displayTemplate, ItemContainerType itemContainerType, IDictionary <string, object> htmlattributes, int index, bool normal, Func <TItem, int, string> getDynamicContainer = null ) { string openTag; string closureTag; GetItemContainerTags( itemContainerType, index, getDynamicContainer, htmlattributes, BasicHtmlHelper.AddField(prefix, "$.Item.Value.ChangedExternally"), !normal, out openTag, out closureTag); return(string.Format("{1} {0} {2}", (Item.Changed ? GetOldContentRendering(prefix, htmlHelper, displayTemplate) : GetContentRendering(prefix, htmlHelper, displayTemplate)), openTag, closureTag)); }
public string GetFullName <F>(Expression <Func <M, F> > expression) { if (expression == null) { throw (new ArgumentNullException("expression")); } return(BasicHtmlHelper.AddField(modelPrefix, ExpressionHelper.GetExpressionText(expression))); }
internal string Render(string name) { return(string.Format(script, BasicHtmlHelper.IdFromName(name), Animated, Unique ? "true": "false", javascriptPersitency() )); }
public static MvcHtmlString ViewList <M>( this HtmlHelper <M> htmlHelper, string groupName, string cssSelected, string selection = null) { if (groupName == null) { throw (new ArgumentNullException("groupName")); } string partialName = groupName + "_selection"; string fullId = BasicHtmlHelper.IdFromName(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(partialName)); string viewSelectionScript = null; switch (MvcEnvironment.Validation(htmlHelper)) { case ValidationType.StandardClient: viewSelectionScript = viewSelectionScriptStandardClient; break; case ValidationType.UnobtrusiveClient: viewSelectionScript = viewSelectionScriptUnobtrusiveClient; break; default: viewSelectionScript = viewSelectionScriptNoClient; break; } if (string.IsNullOrWhiteSpace(selection)) { selection = string.Empty; } string prefix = htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix; if (string.IsNullOrWhiteSpace(prefix)) { prefix = string.Empty; } else { prefix = BasicHtmlHelper.IdFromName(prefix) + "_"; } ValueProviderResult vr = htmlHelper.ViewContext.Controller.ValueProvider.GetValue(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(partialName)); if (vr != null) { string oldres = vr.ConvertTo(typeof(string)) as string; if (!string.IsNullOrWhiteSpace(oldres)) { selection = oldres; } } if (string.IsNullOrWhiteSpace(cssSelected)) { cssSelected = string.Empty; } return (MvcHtmlString.Create( htmlHelper.Hidden(partialName, selection) + string.Format(viewSelectionScript, groupName, fullId, selection, cssSelected, prefix))); }
private static MvcHtmlString _cond <T, F>( this HtmlHelper <T> htmlHelper, Expression <Func <T, F> > expression, ExternalContainerType itemsContainer = ExternalContainerType.koComment, object htmlAttributes = null, string afterRender = null, bool negateCondition = false, string format = null, params LambdaExpression[] otherExpressions) { if (expression == null) { throw (new ArgumentNullException("expression")); } IDictionary <string, object> attributes = null; if (htmlAttributes == null) { attributes = new RouteValueDictionary(); } else if (htmlAttributes is IDictionary <string, object> ) { attributes = htmlAttributes as IDictionary <string, object>; } else { attributes = new RouteValueDictionary(htmlAttributes); } IBindingsBuilder <T> bindings = htmlHelper.ClientBindings(); if (bindings == null) { throw (new ArgumentNullException("bindings")); } string bindingsValue = string.Format( ifScript, bindings.standardString(negateCondition ? "ifnot" : "if", expression, format, otherExpressions), bindings.ValidationType == "UnobtrusiveClient" ? "true" : "false", afterRender == null ? "null" : afterRender); if (attributes.ContainsKey("data-bind")) { attributes["data-bind"] = (attributes["data-bind"] as string) + ", " + bindingsValue; } else { attributes["data-bind"] = bindingsValue; } attributes["data-nobinding"] = "true"; string openTag; string closeTag; BasicHtmlHelper.GetContainerTags(itemsContainer, attributes, out openTag, out closeTag); htmlPush("_ClientControlsFlowStack_", closeTag); return(MvcHtmlString.Create( openTag )); }
public static MvcHtmlString ViewListFor <M>( this HtmlHelper <M> htmlHelper, Expression <Func <M, string> > expression, string groupName, string cssSelected) { if (expression == null) { throw (new ArgumentNullException("expression")); } if (groupName == null) { throw (new ArgumentNullException("groupName")); } string viewSelectionScript = null; switch (MvcEnvironment.Validation(htmlHelper)) { case ValidationType.StandardClient: viewSelectionScript = viewSelectionScriptStandardClient; break; case ValidationType.UnobtrusiveClient: viewSelectionScript = viewSelectionScriptUnobtrusiveClient; break; default: viewSelectionScript = viewSelectionScriptNoClient; break; } string partialName = ExpressionHelper.GetExpressionText(expression); string fullId = BasicHtmlHelper.IdFromName(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(partialName)); string selection = string.Empty; try { selection = expression.Compile().Invoke(htmlHelper.ViewData.Model) as string; } catch { } string prefix = htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix; if (string.IsNullOrWhiteSpace(prefix)) { prefix = string.Empty; } else { prefix = BasicHtmlHelper.IdFromName(prefix) + "_"; } if (string.IsNullOrWhiteSpace(cssSelected)) { cssSelected = string.Empty; } return (MvcHtmlString.Create( htmlHelper.Hidden(partialName, selection) + string.Format(viewSelectionScript, groupName, fullId, selection, cssSelected, prefix))); }
public MvcHtmlString SelectedItemsFilter(IDictionary <string, object> htmlAttributes = null) { return(MvcHtmlString.Create( CurrHtmlHelper.TextBox( BasicHtmlHelper.AddField(Prefix, "$.PackedValue") + DualSelect_SelectedFilter, null, htmlAttributes).ToString() + string.Format(script, controlId, "true") )); }
public void GetCurrState(string currPrefix, int updateIndex, ModelStateDictionary modelState) { string prefix = "$${0}.$.Item.OldValue"; if (!string.IsNullOrWhiteSpace(currPrefix) && currPrefix != "display") { prefix = currPrefix + "." + prefix; } BasicHtmlHelper.ClearRelevantErrors(modelState, string.Format(prefix, updateIndex)); }
public static MvcHtmlString TreeViewToggleEditButtonFor <VM, T>( this HtmlHelper <VM> htmlHelper, Expression <Func <VM, IEnumerable <T> > > expression, string textOrUrlEdit, string cssClassEdit, string textOrUrlUndoEdit, string cssClassUndoEdit, string textOrUrlRedoEdit, string cssClassRedoEdit, ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button) { if (expression == null) { throw (new ArgumentNullException("expression")); } if (textOrUrlEdit == null) { throw (new ArgumentNullException("textOrUrlEdit")); } if (cssClassEdit == null) { throw (new ArgumentNullException("cssClassEdit")); } if (textOrUrlUndoEdit == null) { throw (new ArgumentNullException("textOrUrlUndoEdit")); } if (cssClassUndoEdit == null) { throw (new ArgumentNullException("cssClassUndoEdit")); } if (textOrUrlRedoEdit == null) { throw (new ArgumentNullException("textOrUrlRedoEdit")); } if (cssClassRedoEdit == null) { throw (new ArgumentNullException("cssClassRedoEdit")); } if (MvcEnvironment.Validation(htmlHelper) == ValidationType.StandardClient) { return(MvcHtmlString.Create(string.Empty)); } string id = BasicHtmlHelper.IdFromName(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression))); return(MvcHtmlString.Create( string.Format(initializeToggleEditButtonScript, id, textOrUrlEdit, cssClassEdit, textOrUrlUndoEdit, cssClassUndoEdit, textOrUrlRedoEdit, cssClassRedoEdit) + htmlHelper.ManipulationButton(ManipulationButtonType.Custom, string.Empty, string.Format(toggleEditButtonScript, id, textOrUrlEdit, cssClassEdit, textOrUrlUndoEdit, cssClassUndoEdit, textOrUrlRedoEdit, cssClassRedoEdit), id + "_ToggleEditButton", manipulationButtonStyle, null).ToString())); }
internal HtmlHelper <T> GetHelper(HtmlHelper <M> htmlHelper, string partialPrefix, string prefix) { htmlHelper.ViewContext.Writer.Write( BasicHtmlHelper.RenderDisplayInfo(htmlHelper, this.GetType(), partialPrefix)); ViewDataDictionary <T> dataDictionary = new ViewDataDictionary <T>(FilterDescription); dataDictionary.TemplateInfo.HtmlFieldPrefix = BasicHtmlHelper.AddField(prefix, "$.FilterDescription"); BasicHtmlHelper.CopyRelevantErrors(dataDictionary.ModelState, htmlHelper.ViewData.ModelState, dataDictionary.TemplateInfo.HtmlFieldPrefix); return(new TemplateInvoker <T>().BuildHelper(htmlHelper, dataDictionary)); }
private string pageString(int page) { if (page < 0) { return(string.Format("$('#{0}').val()||'{1}'", BasicHtmlHelper.IdFromName(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(goTextName)), currPage)); } else { return(string.Format("'{0}'", page)); } }
public HtmlHelper <S> To <S>() where S : class { RenderInfo <IDisplayModel> r = htmlHelper.InvokeTransformExt(renderInfo, createHandler <S>(renderInfo.Model), duplicate: true); htmlHelper.ViewContext.Writer.WriteLine(r.GetPartialrendering()); ViewDataDictionary <S> dataDictionary = new ViewDataDictionary <S>(renderInfo.Model as S); dataDictionary.TemplateInfo.HtmlFieldPrefix = BasicHtmlHelper.AddField(r.Prefix, "Item"); BasicHtmlHelper.CopyRelevantErrors(dataDictionary.ModelState, htmlHelper.ViewData.ModelState, dataDictionary.TemplateInfo.HtmlFieldPrefix); return(new TemplateInvoker <S>().BuildHelper(htmlHelper, dataDictionary)); }
internal MvcHtmlString Render(HtmlHelper <M> htmlHelper, string partialPrefix, string prefix, object template) { StringBuilder sb = new StringBuilder(); sb.Append(BasicHtmlHelper.RenderDisplayInfo(htmlHelper, this.GetType(), partialPrefix)); ViewDataDictionary <T> dataDictionary = new ViewDataDictionary <T>(FilterDescription); dataDictionary.TemplateInfo.HtmlFieldPrefix = BasicHtmlHelper.AddField(prefix, "$.FilterDescription"); BasicHtmlHelper.CopyRelevantErrors(dataDictionary.ModelState, htmlHelper.ViewData.ModelState, dataDictionary.TemplateInfo.HtmlFieldPrefix); sb.Append(new TemplateInvoker <T>(template).Invoke <M>(htmlHelper, dataDictionary)); return(MvcHtmlString.Create(sb.ToString())); }
protected string GetOldContentRendering(string prefix, HtmlHelper <TModel> htmlHelper, object template) { ViewDataDictionary <TItem> dataDictionary = new ViewDataDictionary <TItem>(Item.OldValue); if (htmlHelper.ViewData.ContainsKey("ThemeParams")) { dataDictionary["ThemeParams"] = htmlHelper.ViewData["ThemeParams"] as GridDescriptionBase; } dataDictionary.TemplateInfo.HtmlFieldPrefix = BasicHtmlHelper.AddField(prefix, "$.Item.Value"); BasicHtmlHelper.CopyRelevantErrors(dataDictionary.ModelState, htmlHelper.ViewData.ModelState, dataDictionary.TemplateInfo.HtmlFieldPrefix); dataDictionary["status"] = status; return(new TemplateInvoker <TItem>(template).Invoke <TModel>(htmlHelper, dataDictionary)); }
public string GetFullBindingName(LambdaExpression expression) { if (expression == null) { throw (new ArgumentNullException("expression")); } string res = BasicHtmlHelper.AddField(bindingPrefix, ExpressionHelper.GetExpressionText(expression)); if (string.IsNullOrWhiteSpace(res)) { return("$data"); } return(res); }
protected string RenderBasicScripts(CultureInfo format) { if (baseScriptsRendered) { return(string.Empty); } baseScriptsRendered = true; StringBuilder sb = new StringBuilder(); sb.Append(BasicHtmlHelper.RenderDisplayInfo(htmlHelper, this.GetType(), prefix)); bool isClientBlock = htmlHelper.ViewData["ClientBindings"] != null || htmlHelper.ViewContext.HttpContext.Items.Contains("ClientTemplateOn"); sb.Append(string.Format(startScriptFormat, BasicHtmlHelper.IdFromName(BasicHtmlHelper.AddField(this.totalPrefix, "$")), BasicHtmlHelper.JavaScriptDate(min, isClientBlock), BasicHtmlHelper.JavaScriptDate(max, isClientBlock), clientOnChanged != null ? clientOnChanged + " return" : " return;", BasicHtmlHelper.JavaScriptDate(curr), clientMinScript, clientMaxScript, yearCombo ? "true" : "false", dateHidden ? "true" : "false", clientRefreshRegistrations, this.dateInCalendar ? "true" : "false", BasicHtmlHelper.GetAttributesString(attributeExtensions), totalPrefix )); sb.Append(BasicHtmlHelper.TrueValue(htmlHelper, this.totalPrefix, curr)); FormatAttribute[] formatAttributes = pAccesor[typeof(FormatAttribute)] as FormatAttribute[]; if (formatAttributes != null && formatAttributes.Length > 0) { sb.Append(BasicHtmlHelper.FormattedValueString(htmlHelper, this.totalPrefix, formatAttributes[0].HtmlEncode ? htmlHelper.Encode(formatAttributes[0].GetDisplay(curr)) : formatAttributes[0].GetDisplay(curr))); } else { DisplayFormatAttribute[] dFormatAttributes = pAccesor[typeof(DisplayFormatAttribute)] as DisplayFormatAttribute[]; if (dFormatAttributes != null && dFormatAttributes.Length > 0) { sb.Append(BasicHtmlHelper.FormattedValueString(htmlHelper, this.totalPrefix, dFormatAttributes[0].HtmlEncode ? htmlHelper.Encode( new FormatAttribute(dFormatAttributes[0]).GetDisplay(curr)) : new FormatAttribute(dFormatAttributes[0]).GetDisplay(curr))); } } if (format != null) { WriteMonthes(sb, format); } return(sb.ToString()); }
public MvcHtmlString Invoke <S>(object template) where S : class { if (template == null) { throw(new ArgumentNullException("template")); } RenderInfo <IDisplayModel> r = htmlHelper.InvokeTransformExt(renderInfo, createHandler <S>(renderInfo.Model), duplicate: true); ViewDataDictionary <S> dataDictionary = new ViewDataDictionary <S>(renderInfo.Model as S); dataDictionary.TemplateInfo.HtmlFieldPrefix = BasicHtmlHelper.AddField(r.Prefix, "Item"); BasicHtmlHelper.CopyRelevantErrors(dataDictionary.ModelState, htmlHelper.ViewData.ModelState, dataDictionary.TemplateInfo.HtmlFieldPrefix); return(MvcHtmlString.Create(r.GetPartialrendering() + (new TemplateInvoker <S>().Invoke(htmlHelper, dataDictionary)))); }
internal string GetChangedAndOldValuesRendering(string prefix, HtmlHelper <TModel> htmlHelper) { StringBuilder sb = new StringBuilder(); sb.Append(BasicHtmlHelper.SafeHidden(htmlHelper, BasicHtmlHelper.AddField(prefix, "$.Item.Changed"), this.Item.Changed).ToString()); if (this.Item != null && this.Item.OldValue != null) { prefix = BasicHtmlHelper.AddField(prefix, "$.Item.OldValue"); if (fieldsToStore != null) { foreach (LambdaExpression l in fieldsToStore) { object val = null; string name = ExpressionHelper.GetExpressionText(l); try { val = l.Compile().DynamicInvoke(this.Item.OldValue); } catch { } if (val is IConvertible || val is Guid) { string res = BasicHtmlHelper.SafeHidden(htmlHelper, BasicHtmlHelper.AddField(prefix, name), val).ToString(); sb.Append(res); } else { MVCControlsToolkit.Controls.Bindings.ModelTranslatorLight model = new MVCControlsToolkit.Controls.Bindings.ModelTranslatorLight(); model.ImportFromModel(val); sb.Append(BasicHtmlHelper.RenderDisplayInfo(htmlHelper, typeof(MVCControlsToolkit.Controls.Bindings.ModelTranslatorLight), BasicHtmlHelper.AddField(prefix, name))); string res = BasicHtmlHelper.SafeHidden(htmlHelper, BasicHtmlHelper.AddField(prefix, name + ".$.JSonModel"), model.JSonModel).ToString(); sb.Append(res); } } } else { Stack <object> recursionControl = new Stack <object>(); recursionControl.Push(this.Item.OldValue); addObjectPropertiesTorender(prefix, htmlHelper, sb, propertiesToStore, this.Item.OldValue, recursionControl); recursionControl.Pop(); } } return(sb.ToString()); }
private static void RenderWrapper <VM>(HtmlHelper <VM> htmlHelper, string partialPrefix, ITreeViewNodeContainer wrapper, StringBuilder sbInit) { sbInit.Append(htmlHelper.GenericInput(InputType.Hidden, BasicHtmlHelper.AddField(partialPrefix, "$.Closed"), wrapper.Closed).ToString()); sbInit.Append(htmlHelper.GenericInput(InputType.Hidden, BasicHtmlHelper.AddField(partialPrefix, "$.FatherOriginalId"), wrapper.FatherOriginalId).ToString()); sbInit.Append(htmlHelper.GenericInput(InputType.Hidden, BasicHtmlHelper.AddField(partialPrefix, "$.OriginalId"), wrapper.OriginalId).ToString()); sbInit.Append(htmlHelper.GenericInput(InputType.Hidden, BasicHtmlHelper.AddField(partialPrefix, "$.PositionAsSon"), wrapper.PositionAsSon).ToString()); sbInit.Append(htmlHelper.GenericInput(InputType.Hidden, BasicHtmlHelper.AddField(partialPrefix, "$.SonCollectionName"), wrapper.SonCollectionName).ToString()); sbInit.Append(htmlHelper.GenericInput(InputType.Hidden, BasicHtmlHelper.AddField(partialPrefix, "$.SonNumber"), wrapper.SonNumber).ToString()); }
public object ExportToModel(Type targetType, params object[] context) { if (string.IsNullOrWhiteSpace(JSonModel)) { return(null); } if (!targetType.IsAssignableFrom(typeof(T))) { throw (new NotSupportedException(string.Format(ControlsResources.NotCompatibleTypes, typeof(T).FullName, targetType.FullName))); } object result = BasicHtmlHelper.ClientDecode(JSonModel, typeof(T)); Validate(result, null, null, prefix); return(result); }
protected string RenderPageButton(string textOrUrl, string disabledTexOrUrl, int index, PageButtonStyle pageButtonStyle, PageButtonType?pageButtonType, IDictionary <string, object> htmlAttributes = null, bool encoded = true) { if (htmlAttributes == null) { htmlAttributes = new Dictionary <string, object>(); } string buttonType = getPageButtonClass(pageButtonType); string buttonId = fieldId + "_" + buttonType; if (!pageButtonType.HasValue) { if (index < 0) { buttonId = buttonId + "_" + (-index).ToString(CultureInfo.InvariantCulture); } else { buttonId = buttonId + index.ToString(CultureInfo.InvariantCulture); } htmlAttributes["data-pager-index"] = index.ToString(CultureInfo.InvariantCulture); } htmlAttributes["id"] = buttonId; htmlAttributes["data-pager-button"] = buttonType; BasicHtmlHelper.AddClass(htmlAttributes, fieldId + "_class"); BasicHtmlHelper.SetDefaultStyle(htmlAttributes, "cursor", "pointer"); switch (pageButtonStyle) { case PageButtonStyle.Button: htmlAttributes["type"] = "button"; htmlAttributes["value"] = htmlHelper.Encode(textOrUrl); return(string.Format(buttonSchema, BasicHtmlHelper.GetAttributesString(htmlAttributes))); case PageButtonStyle.Image: htmlAttributes["src"] = textOrUrl; if (disabledTexOrUrl != null) { htmlAttributes["data-disabled-src"] = disabledTexOrUrl; htmlAttributes["data-enabled-src"] = textOrUrl; } return(string.Format(imgSchema, BasicHtmlHelper.GetAttributesString(htmlAttributes))); default: htmlAttributes["href"] = "javascript:void(0);"; return(string.Format(linkSchema, BasicHtmlHelper.GetAttributesString(htmlAttributes), encoded ? htmlHelper.Encode(textOrUrl): textOrUrl)); } }