Пример #1
0
        /// <summary>
        /// Generates the script neccessary to open the dialog.
        /// </summary>
        /// <remarks>
        /// <p>Calling <see cref="DialogWindowBase.Open"/> will cause this script to be sent to the client browser.</p>
        /// <p>This method can also be used to open the dialog on the client without postingback.</p>
        /// <p>This method is only public for developers who want to customize how and when the window is opened via code or a custom server control.</p>
        /// </remarks>
        public override String GetDialogOpenScript()
        {
            StringBuilder finalUrl = new StringBuilder();

            finalUrl.Append(this.ResolveUrl(this.TargetUrl.ToString()));
            String argAppender = "&";

            if (TargetUrl.ToString().IndexOf("?") == -1)
            {
                argAppender = "?";
            }
            if (this.dialogArguments != null)
            {
                foreach (String key in this.dialogArguments.Keys)
                {
                    finalUrl.Append(argAppender);
                    if (argAppender == "?")
                    {
                        argAppender = "&";
                    }
                    finalUrl.Append(HttpUtility.UrlEncode(key));
                    finalUrl.Append("=");
                    finalUrl.Append(HttpUtility.UrlEncode(this.dialogArguments[key]));
                }
            }
            NameValueCollection features = this.GetStandardFeatures();

            if (this.WindowHeight != Unit.Empty)
            {
                features["height"]      = this.WindowHeight.Value.ToString();
                features["innerHeight"] = this.WindowHeight.Value.ToString();
            }
            if (this.WindowWidth != Unit.Empty)
            {
                features["width"]      = this.WindowWidth.Value.ToString();
                features["innerWidth"] = this.WindowWidth.Value.ToString();
            }

            return(this.GetDialogOpenScript(new Uri(finalUrl.ToString()), features));
        }