本文整理汇总了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");
}
示例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));
}
}
}
}