コード例 #1
0
 /// <summary>
 /// Executes the client script.
 /// Start: 在Page物件的 form runat= server 元素的結束標記之前發出該腳本,
 /// Block: 在Page物件的 form runat= server 元素的開始標記後立即發出該腳本
 /// </summary>
 /// <param name="page">The page.</param>
 /// <param name="script">The script.</param>
 /// <param name="registerType">Type of the register.</param>
 public static void ExecuteClientScript(
     Page page,
     string script,
     RegisterScriptType registerType)
 {
     ExecuteClientScript(page, script, false, registerType);
 }
コード例 #2
0
 /// <summary>
 /// Shows the message.
 /// Start: 在Page物件的 form 元素的結束標記之前發出alert(msg),
 /// Block: 在Page物件的 form 元素的開始標記後立即發出alert(msg)
 /// </summary>
 /// <param name="page">The page.</param>
 /// <param name="message">The message.</param>
 /// <param name="registerType">RegisterScriptType.</param>
 /// <param name="isCleanMessage">if set to <c>true</c> [is clean message].</param>
 public static void ShowMessage(
     Page page,
     string message,
     RegisterScriptType registerType)
 {
     ShowMessage(page, message, registerType, true);
 }
コード例 #3
0
 /// <summary>
 /// Shows the message and Redirect.
 /// Start: 在Page物件的 form 元素的結束標記之前發出alert(msg),
 /// Block: 在Page物件的 form 元素的開始標記後立即發出alert(msg)
 /// </summary>
 /// <param name="page">The page.</param>
 /// <param name="message">The message.</param>
 /// <param name="redirectUri">The redirect URI (Reolad: redirectURI = window.location.href).</param>
 /// <param name="registerType">RegisterScriptType.</param>
 /// Reolad: redirectURI = window.location.href
 public static void ShowMessage(
     Page page,
     string message,
     string redirectUri,
     RegisterScriptType registerType)
 {
     ShowMessage(page, message, redirectUri, null, registerType);
 }
コード例 #4
0
        public static void ShowMessage(
            Page page,
            string message,
            RegisterScriptType registerType,
            bool isCleanScript)
        {
            var clientScript = string.Format(
                "alert('{0}');",
                isCleanScript ? CleanMessage(message) : message
                );

            ExecuteClientScript(page, FormatClientScript(clientScript), registerType);
        }
コード例 #5
0
        /// <summary>
        /// Shows the message and Redirect.
        /// Start: 在Page物件的 form 元素的結束標記之前發出alert(msg),
        /// Block: 在Page物件的 form 元素的開始標記後立即發出alert(msg)
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="message">The message.</param>
        /// <param name="redirectUri">The redirect URI (Reolad: redirectURI = window.location.href).</param>
        /// <param name="target">The target (top or this).</param>
        /// <param name="registerType">RegisterScriptType.</param>
        public static void ShowMessage(
            Page page,
            string message,
            string redirectUri,
            string target,
            RegisterScriptType registerType)
        {
            string script = !string.IsNullOrWhiteSpace(target)
                ? string.Format(@"window.alert('{0}');{1}.location.href='{2}';", message, target, redirectUri)
                : string.Format(@"window.alert('{0}');location.href='{1}';", message, redirectUri);

            ExecuteClientScript(page, FormatClientScript(script), registerType);
        }
コード例 #6
0
        /// <summary>
        /// Executes the client script.
        /// Start: 在Page物件的 form runat= server 元素的結束標記之前發出該腳本,
        /// Block: 在Page物件的 form runat= server 元素的開始標記後立即發出該腳本
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="script">The client script.</param>
        /// <param name="isFormatClientScript">if set to <c>true</c> [is format client script].</param>
        /// <param name="registerType">RegisterScriptType.</param>
        public static void ExecuteClientScript(
            Page page,
            string script,
            bool isFormatClientScript,
            RegisterScriptType registerType)
        {
            string scriptString = isFormatClientScript
                ? FormatClientScript(script)
                : script;

            var strKey = (Guid.NewGuid().ToString()).Replace("-", "").ToUpper();

            switch (registerType)
            {
            case RegisterScriptType.Start:
                page.ClientScript.RegisterStartupScript(page.GetType(), strKey, scriptString);
                break;

            case RegisterScriptType.Block:
                page.ClientScript.RegisterClientScriptBlock(page.GetType(), strKey, scriptString);
                break;
            }
        }