⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utility.cs

📁 AJAX 应用 实现页面的无刷新
💻 CS
字号:
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

using System;
using System.Web.UI;

namespace AjaxControlToolkit
{
    /// <summary>
    /// Utility methods for use with the Toolkit
    /// </summary>
    public static class Utility
    {
        /// <summary>
        /// Set the focus of a control after all the client-side behaviors
        /// have finished initializing
        /// </summary>
        /// <param name="control">Control to focus</param>
        /// <remarks>
        /// SetFocusOnLoad is a replacement for ScriptManager.SetFocus and
        /// Page.SetFocus that will focus the control after any client-side
        /// behaviors have been initialized.
        /// </remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Justification = "Assembly is not localized")]
        public static void SetFocusOnLoad(Control control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control", "Control cannot be null!");
            }

            string script =
                "(function() { " +
                    "var fn = function() { " +
                        "var control = $get('" + control.ClientID + "'); " +
                        "if (control && control.focus) { control.focus(); } " +
                        "Sys.Application.remove_load(fn);" +
                    "};" +
                    "Sys.Application.add_load(fn);" +
                "})();";
            ScriptManager.RegisterStartupScript(control.Page, control.GetType(),
                control.ClientID + "_SetFocusOnLoad", script, true);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -