public static PageMode GetPageMode(this HtmlHelper htmlHelper, Type type, string cutomePrefixname) { var keyName = BaseControllerUtility.GetPagModeKeyName(type, cutomePrefixname); if (htmlHelper.ViewData == null || htmlHelper.ViewData[keyName] == null) { return(PageMode.None); } return(htmlHelper.ViewData[keyName].ToString().ToEnum <PageMode>()); }
public static string GetPageModeClientId(this HtmlHelper htmlHelper, Type type, string cutomePrefixname) { return(BaseControllerUtility.GetPagModeKeyName(type, cutomePrefixname)); }
public static void PrepareModel(this HtmlHelper htmlHelper, Type type, string cutomePrefixname) { try { if (htmlHelper.ViewContext == null || htmlHelper.ViewContext.ViewData == null) { return; } var stringWriter = new StringWriter(); var html32TextWriter = new Html32TextWriter(stringWriter); var keyName = BaseControllerUtility.GetModelKeyName(type, cutomePrefixname); var pagModeKeyName = BaseControllerUtility.GetPagModeKeyName(type, cutomePrefixname); var modifyBehaviorStausKeyName = BaseControllerUtility.GetModifyBehaviorStausKeyName(type, cutomePrefixname); var cultureKeyName = BaseControllerUtility.GetCultureKeyName(type, cutomePrefixname); var updateFormDataKeyName = BaseControllerUtility.GetUpdateFormDataKeyName(type, cutomePrefixname); var controllerStatusKeyName = BaseControllerUtility.GetControllerStatusKeyName(type, cutomePrefixname); if (htmlHelper.ViewContext.ViewData.ContainsKey(keyName)) { var split = Radyn.Utility.Serialize.JsonDeserialize <List <KeyValuePair <string, object> > >(htmlHelper.ViewContext.ViewData[keyName].ToString()); foreach (var pair in split) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), pair.Key); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), pair.Key); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), pair.Value != null ? pair.Value.ToString() : null); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } } if (htmlHelper.ViewContext.ViewData.ContainsKey(pagModeKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), pagModeKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), pagModeKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[pagModeKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewData.ContainsKey(modifyBehaviorStausKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), modifyBehaviorStausKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), modifyBehaviorStausKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[modifyBehaviorStausKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewData.ContainsKey(cultureKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), cultureKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), cultureKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[cultureKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewData.ContainsKey(updateFormDataKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), updateFormDataKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), updateFormDataKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[updateFormDataKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewData.ContainsKey(controllerStatusKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), controllerStatusKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), controllerStatusKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[controllerStatusKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } htmlHelper.ViewContext.Writer.Write(stringWriter); } catch { } }