当前位置: 首页>>代码示例>>C#>>正文


C# ScriptOptions.Is方法代码示例

本文整理汇总了C#中ScriptOptions.Is方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptOptions.Is方法的具体用法?C# ScriptOptions.Is怎么用?C# ScriptOptions.Is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScriptOptions的用法示例。


在下文中一共展示了ScriptOptions.Is方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JavaScript

        /// <summary>Registers a script block on a page.</summary>
        /// <param name="page">The page onto which to added the script.</param>
        /// <param name="script">The script to add.</param>
        /// <param name="position">Where to add the script.</param>
        /// <param name="options">Script registration options.</param>
        public static void JavaScript(this Page page, string script, ScriptPosition position, ScriptOptions options)
        {
            if (page == null) throw new ArgumentNullException("page");

            if (position == ScriptPosition.Header)
            {
                JavaScript(page, script, options);
            }
            else if (position == ScriptPosition.Bottom)
            {
                string key = script.GetHashCode().ToString();
                if (options.Is(ScriptOptions.None))
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, script);
                else if (options.Is(ScriptOptions.ScriptTags))
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, script, true);
                else if (options.Is(ScriptOptions.DocumentReady))
                {
                    page.JQuery();
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, EmbedDocumentReady(script), true);
                }
                else if (options.Is(ScriptOptions.Include))
                    page.ClientScript.RegisterClientScriptInclude(key, Url.ResolveTokens(script));
                else
                    throw new ArgumentException("options");
            }
            else
                throw new ArgumentException("position");
        }
开发者ID:pauldotknopf,项目名称:Noodle,代码行数:33,代码来源:Register.cs

示例2: JavaScript

        public static void JavaScript(this Page page, string script, ScriptOptions options)
        {
            if (page == null) throw new ArgumentNullException("page");
            
            if (page.Items[script] == null)
            {
                PlaceHolder holder = GetPlaceHolder(page);

                if (options.Is(ScriptOptions.Include))
                {
                    AddScriptInclude(page, script, holder, options.Is(ScriptOptions.Prioritize));
                }
                else if (options.Is(ScriptOptions.None))
                {
                    holder.Page.Items[script] = AddString(holder, script, options.Is(ScriptOptions.Prioritize));
                }
                else
                {
                    Script scriptHolder = GetScriptHolder(page);
                    if (options.Is(ScriptOptions.ScriptTags))
                    {
                        holder.Page.Items[script] = AddString(scriptHolder, script + Environment.NewLine, Is(options, ScriptOptions.Prioritize));
                    }
                    else if (options.Is(ScriptOptions.DocumentReady))
                    {
                        JQuery(page);
                        holder.Page.Items[script] = AddString(scriptHolder, EmbedDocumentReady(script) + Environment.NewLine, options.Is(ScriptOptions.Prioritize));
                    }
                }
            }
        }
开发者ID:jackiezhang926,项目名称:n2cms,代码行数:31,代码来源:Register.cs


注:本文中的ScriptOptions.Is方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。