本文整理汇总了C#中System.Web.UI.HtmlControls.HtmlGenericControl.ResolveUrl方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlGenericControl.ResolveUrl方法的具体用法?C# HtmlGenericControl.ResolveUrl怎么用?C# HtmlGenericControl.ResolveUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlControls.HtmlGenericControl
的用法示例。
在下文中一共展示了HtmlGenericControl.ResolveUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildChildControl
private void BuildChildControl(string scriptUrl, ScriptPositionMode mode)
{
switch (mode)
{
case ScriptPositionMode.Header:
HtmlGenericControl ctr = new HtmlGenericControl("script");
ctr.Attributes.Add("language", "javascript");
ctr.Attributes.Add("type", "text/javascript");
ctr.Attributes.Add("src", ctr.ResolveUrl(scriptUrl));
this.Controls.Add(ctr);
break;
case ScriptPositionMode.ScriptManager:
ScriptManager sm = ScriptManager.GetCurrent(this.Page);
ExceptionHelper.TrueThrow(sm == null, Resources.DeluxeWebResource.E_NoScriptManager);
sm.Scripts.Add(new ScriptReference(scriptUrl));
break;
case ScriptPositionMode.BodyStart:
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(),
string.Format(_C_SCRIPT_FORMAT, scriptUrl), false);
break;
case ScriptPositionMode.BodyEnd:
this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
string.Format(_C_SCRIPT_FORMAT, scriptUrl), false);
break;
}
}
示例2: CreateJavaScriptLink
public HtmlGenericControl CreateJavaScriptLink(string scriptFilePath, string Tip = "")
{
var script = new HtmlGenericControl();
script.TagName = "script";
if (Tip != "")
{
script.Attributes.Add("type", "text/javascript");
}
script.Attributes.Add("src", script.ResolveUrl(scriptFilePath));
return script;
}