Beispiel #1
0
        protected ContentResult CloseFrameDialog(DialogCloseOption option)
        {
            var ret     = "";
            var builder = new TagBuilder("script");

            builder.MergeAttribute("type", "text/javascript");

            if (Request["ReloadURL"] != null && Request["ReloadID"] != null)
            {
                ret += "parent." + Javascript.RemoteFunc(new RemoteOption
                {
                    URL    = Request["ReloadURL"],
                    Update = Request["ReloadID"]
                });
            }
            builder.InnerHtml += ret + ";";
            if (option.Message != null)
            {
                builder.InnerHtml += "alert(\"" + option.Message + "\");";
            }
            if (option.RunJS == null)
            {
                option.RunJS = Request.Params.Get("RunJS");
            }
            if (!string.IsNullOrEmpty(option.RunJS))
            {
                builder.InnerHtml += "parent." + option.RunJS + ";";
            }
            //builder.InnerHtml += "parent.Core.dialog.closeBox();";
            return(Content(builder.ToString()));
        }
        /// <summary>
        /// Buttons to remote.
        /// </summary>
        /// <param name="html">The HTML.</param>
        /// <param name="name">The name.</param>
        /// <param name="cssClass">The CSS class.</param>
        /// <param name="options">The options.</param>
        /// <param name="htmlAttr">The HTML attr.</param>
        /// <returns></returns>
        public static String ButtonToRemote(this HtmlHelper html, String name, String cssClass, RemoteOption options, object htmlAttr)
        {
            var onClick = Javascript.RemoteFunc(options);
            var builder = new TagBuilder("input");

            builder.MergeAttribute("type", "button");
            builder.MergeAttribute("onClick", onClick);
            builder.MergeAttribute("value", name);
            if (cssClass != "")
            {
                builder.MergeAttribute("class", cssClass);
            }

            builder.MergeAttributes((htmlAttr == null) ? new RouteValueDictionary() : new RouteValueDictionary(htmlAttr));

            return(builder.ToString());
        }
        /// <summary>
        /// close any opened dialog
        /// </summary>
        /// <returns></returns>
        protected ContentResult CloseFrameDialog()
        {
            var ret     = "";
            var builder = new TagBuilder("script");

            builder.MergeAttribute("type", "text/javascript");


            if (Request["ReloadURL"] != null && Request["ReloadID"] != null)
            {
                ret += "parent." + Javascript.RemoteFunc(new RemoteOption
                {
                    URL    = Request["ReloadURL"],
                    Update = Request["ReloadID"]
                });
            }
            builder.InnerHtml = ret + ";parent.Core.dialog.closeBox()";

            return(Content(builder.ToString()));
        }
 /// <summary>
 /// remote function
 /// </summary>
 /// <param name="html"></param>
 /// <param name="option"></param>
 /// <returns></returns>
 public static String RemoteFunc(this HtmlHelper html, RemoteOption option)
 {
     return(Javascript.RemoteFunc(option));
 }