本文整理汇总了C#中System.Web.UI.HtmlControls.HtmlLink类的典型用法代码示例。如果您正苦于以下问题:C# HtmlLink类的具体用法?C# HtmlLink怎么用?C# HtmlLink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlLink类属于System.Web.UI.HtmlControls命名空间,在下文中一共展示了HtmlLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintWebControl
public static void PrintWebControl(Control ctrl, string Script)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
pg.StyleSheetTheme = "../CSS/order.css";
if (Script != string.Empty)
{
pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
}
HtmlLink link = new HtmlLink();
link.Href = "../CSS/order.css";
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write("<head runat='server'> <title>Printer - Bản in tại Support.evnit.evn.com.vn</title> <link type='text/css' rel='stylesheet' href='../CSS/order.css'><link type='text/css' rel='stylesheet' href='../CSS/style.css'></head>");
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
}
示例2: CreateChildControls
/// <summary>
/// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
/// </summary>
protected override void CreateChildControls()
{
base.CreateChildControls();
ErrorControl errorControl = new ErrorControl();
if (this.IsAsyncPostBackRequest)
{
Controls.Add(errorControl);
}
else
{
HtmlGenericControl html = new HtmlGenericControl("html");
HtmlHead head = new HtmlHead();
HtmlLink link = new HtmlLink();
link.Href = HttpRuntime.AppDomainAppVirtualPath + "/UIBase/Styles/GlobalReset.css";
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("type", "text/css");
head.Controls.Add(link);
html.Controls.Add(head);
Controls.Add(html);
HtmlGenericControl body = new HtmlGenericControl("body");
body.Attributes.Add("style", "padding: 10px");
body.Controls.Add(errorControl);
html.Controls.Add(body);
}
}
示例3: RegisterCssInclude
public static void RegisterCssInclude(this ClientScriptManager clientScriptManager, string cssUrl, ResourceInsertPosition position)
{
if (cssUrl.StartsWith("~"))
cssUrl = VirtualPathUtility.ToAbsolute(cssUrl);
Page page = (Page)HttpContext.Current.Handler;
if (page.Items[cssUrl] == null)
{
HtmlLink link = new HtmlLink();
link.Href = cssUrl;
link.Attributes["type"] = "text/css";
link.Attributes["rel"] = "stylesheet";
link.Attributes["title"] = "Default Style";
switch (position)
{
case ResourceInsertPosition.HeaderTop:
{
int index = (int)(page.Items["__CssResourceIndex"] ?? 0);
page.Header.Controls.AddAt(index, link);
page.Items["__CssResourceIndex"] = ++index;
}
break;
case ResourceInsertPosition.HeaderBottom:
page.Header.Controls.Add(link);
break;
case ResourceInsertPosition.BodyBottom:
page.Form.Controls.Add(link);
break;
}
page.Items[cssUrl] = new object();
}
}
示例4: addStyleSheet
public static void addStyleSheet(string css, string key, Page currentPage, WebControl control)
{
ControlCollection ctrls = currentPage.Controls;
if (currentPage.Master != null)
ctrls = currentPage.Master.Controls;
foreach (Control ctrl in ctrls)
{
if (ctrl.GetType().Name == "HtmlHead")
{
ctrls = ctrl.Controls;
break;
}
}
if (key != null)
{
foreach (Control ctrl in ctrls)
{
if (ctrl.ID == key)
return;
}
}
string url = currentPage.ClientScript.GetWebResourceUrl(control.GetType(), "ESWCtrls.ResEmbed.Styles." + css);
HtmlLink link = new HtmlLink();
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("media", "screen");
link.Href = url;
link.ID = key;
ctrls.Add(new LiteralControl("\n"));
ctrls.Add(link);
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
String ukeyString = Request.QueryString["ukey"];
int inukey = ukeyString == null ? -1 : int.Parse(ukeyString);
ukeyHiddenField.Value = inukey.ToString();
TwitterLink.Visible = inukey != -1;
FaceBookLink.Visible = inukey != -1;
if (inukey == -1)
inukey = FacesLite.GetRandomUkey(inukey);
FaceUkeyLabel.Text = " " + inukey.ToString();
Image1.ImageUrl = String.Format("https://s3.amazonaws.com/FaceSpace/Faces/{0}.jpg", inukey);
Image2.ImageUrl = String.Format("https://s3.amazonaws.com/FaceSpace/Faces/{0}.anti.jpg", inukey);
Image3.ImageUrl = String.Format("https://s3.amazonaws.com/FaceSpace/Faces/{0}.reconstituted.jpg", inukey);
Image3.Attributes.Add("title", "Synthetic, Reconstructed Face");
SynthFaceLink.NavigateUrl = String.Format("http://facefield.org/SynthFace.aspx?ukey={0}", inukey);
SpectrumLink.NavigateUrl = String.Format("http://facefield.org/Carousel.aspx?ukey={0}", inukey);
TwitterLink.NavigateUrl = String.Format("http://twitter.com/share?text={0}&url={1}",
HttpUtility.UrlEncode("My anti-face looks just like me. Not.\n#antiface @face_field"),
Request.Url
);
FaceBookLink.NavigateUrl = String.Format("https://www.facebook.com/sharer/sharer.php?u={0}", Request.Url);
// tell facebook which thumbnail to use.
HtmlLink canonical = new HtmlLink();
canonical.Href = String.Format("https://s3.amazonaws.com/FaceSpace/Faces/{0}.thumb.anti.jpg", inukey);
canonical.Attributes["rel"] = "image_src";
Page.Header.Controls.Add(canonical);
}
示例6: Page_Init
protected void Page_Init(object sender, EventArgs e)
{
using (HtmlLink stylesheet = new HtmlLink())
{
string path = "/bundles/master-page.css";
if (CultureManager.IsRtl())
{
path = path.Replace("css", "rtl.css");
}
stylesheet.Href = path;
stylesheet.Attributes["rel"] = "stylesheet";
stylesheet.Attributes["type"] = "text/css";
stylesheet.Attributes["media"] = "all";
this.Page.Header.Controls.Add(stylesheet);
}
if (Offices.GetOffices(AppUsers.GetCurrentUserDB()).Any())
{
this.Response.Redirect("~/SignIn.aspx");
}
this.RegisterJavascript();
}
示例7: AddLink
protected void AddLink(Control cssRoot, int InsertAt, HtmlLink link)
{
if (string.IsNullOrEmpty(Condition))
{
if (InsertAt == -1)
{
cssRoot.Controls.Add(link);
}
else
{
cssRoot.Controls.AddAt(InsertAt, link);
}
}
else
{
var openif = new Literal();
openif.Text = string.Format("<!--[if {0}]>", Condition);
var closeif = new Literal();
closeif.Text = "<![endif]-->";
if (InsertAt == -1)
{
cssRoot.Controls.Add(openif);
cssRoot.Controls.Add(link);
cssRoot.Controls.Add(closeif);
}
else
{
//Since we want to add at a specific location, we do this in reverse order
//this allows us to use the same insertion point
cssRoot.Controls.AddAt(InsertAt, closeif);
cssRoot.Controls.AddAt(InsertAt, link);
cssRoot.Controls.AddAt(InsertAt, openif);
}
}
}
示例8: SetCanonicalUrl
protected virtual void SetCanonicalUrl(string canonicalUrl)
{
if (String.IsNullOrEmpty(canonicalUrl))
{
throw new Exception("Empty canonical url");
}
canonicalUrl = canonicalUrl.ToLower();
if (!String.IsNullOrEmpty(canonicalUrl))
{
var requestUrl = Request.Url.ToString();
if (requestUrl != canonicalUrl && requestUrl != canonicalUrl + "default.aspx" /*&& !requestUrl.Contains("localhost")*/)
{
Response.Redirect(canonicalUrl);
}
}
if (!_canonicalUrlAdded)
{
var link = new HtmlLink();
link.Attributes["rel"] = "canonical";
link.Href = canonicalUrl;
Header.Controls.Add(link);
_canonicalUrlAdded = true;
}
else
{
throw new Exception("Canonical url already added");
}
}
示例9: AddStyleSheet
public void AddStyleSheet(Page page, string cssPath)
{
HtmlLink link = new HtmlLink();
link.Href = cssPath;
link.Attributes["rel"] = "stylesheet";
link.Attributes["type"] = "text/css";
}
示例10: AddToClientScriptManager
/// <summary>
/// Adds to client script manager.
/// </summary>
/// <param name="page">The page.</param>
/// <param name="link">The link.</param>
private static void AddToClientScriptManager(Page page, HtmlLink link)
{
HtmlTextWriter writer = new HtmlTextWriter(new StringWriter(new StringBuilder()));
link.RenderControl(writer);
page.ClientScript.RegisterClientScriptBlock(typeof(Page),
writer.InnerWriter.ToString(), writer.InnerWriter.ToString());
}
示例11: DoSEO
protected void DoSEO()
{
HtmlLink canonicalTag = new HtmlLink();
canonicalTag.Attributes.Add("rel", "canonical");
// Set page title
((DotNetNuke.Framework.CDefault)this.Page).Title = ModuleConfiguration.ModuleTitle;
if (Request.QueryString["target"] == "ingredient")
{// Eventual target will be a list of ingredients--show the ingredient div
// Set page meta description
((DotNetNuke.Framework.CDefault)this.Page).Description = "Browse liquors and mixers by alcohol proof.";
// Set page link canonical tag
canonicalTag.Href = ConfigurationManager.AppSettings["SiteUrl"] + "ingredients/browse/proof";
}
else
{// Eventual target will be a list of drinks--show the drink div
// Set page meta description
((DotNetNuke.Framework.CDefault)this.Page).Description = "Browse drink recipes by the drink's alcohol proof.";
// Set page link canonical tag
canonicalTag.Href = ConfigurationManager.AppSettings["SiteUrl"] + "drinks/browse/proof";
}
((DotNetNuke.Framework.CDefault)this.Page).Header.Controls.Add(canonicalTag);
}
示例12: SetStyleSheet
internal void SetStyleSheet()
{
if ((this.LinkedStyleSheets != null) && (this.LinkedStyleSheets.Length > 0))
{
if (this.Page.Header == null)
{
throw new InvalidOperationException(System.Web.SR.GetString("Page_theme_requires_page_header"));
}
int num = 0;
foreach (string str in this.LinkedStyleSheets)
{
HtmlLink child = new HtmlLink {
Href = str
};
child.Attributes["type"] = "text/css";
child.Attributes["rel"] = "stylesheet";
if (this._styleSheetTheme)
{
this.Page.Header.Controls.AddAt(num++, child);
}
else
{
this.Page.Header.Controls.Add(child);
}
}
}
}
示例13: RegisterEmbeddedClientResource
/// <summary>
/// Registers the embedded client resource.
/// </summary>
/// <param name="page">The page.</param>
/// <param name="resourceContainer">The type containing the embedded resource</param>
/// <param name="resourceName">Name of the resource.</param>
/// <param name="type">The type.</param>
public static void RegisterEmbeddedClientResource(this Page page, Type resourceContainer, string resourceName, ClientDependencyType type)
{
var target = page.Header;
// if there's no <head runat="server" /> don't throw an exception.
if (target != null)
{
switch (type)
{
case ClientDependencyType.Css:
// get the urls for the embedded resources
var resourceUrl = page.ClientScript.GetWebResourceUrl(resourceContainer, resourceName);
var link = new HtmlLink();
link.Attributes.Add("href", resourceUrl);
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
target.Controls.Add(link);
break;
case ClientDependencyType.Javascript:
page.ClientScript.RegisterClientScriptResource(resourceContainer, resourceName);
break;
default:
break;
}
}
}
示例14: MakeStyleTag
private static HtmlLink MakeStyleTag(string path)
{
HtmlLink ctrl = new HtmlLink {Href = path};
ctrl.Attributes.Add("rel", "stylesheet");
ctrl.Attributes.Add("type", "text/css");
return ctrl;
}
示例15: OnInit
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
// Check for customization parameters
ApplicationName = Request.Params["AppName"] ?? ImageServerConstants.DefaultApplicationName;
SplashScreenUrl = Request.Params["SplashScreenUrl"] ?? DefaultSplashScreenPath;
CssClassName = Request.Params["CssClassName"];
CustomCssUrl = Request.Params["CssUrl"];
if (!string.IsNullOrEmpty(CssClassName))
{
this.PageBody.Attributes["class"] += " " + CssClassName;
}
if (!string.IsNullOrEmpty(CustomCssUrl))
{
// include the custom css (this will append to the end of the list and will overwrite the default css)
var stylesheet = new HtmlLink { Href = CustomCssUrl };
stylesheet.Attributes.Add("rel", "stylesheet");
stylesheet.Attributes.Add("type", "text/css");
Page.Header.Controls.Add(stylesheet);
}
SetSplashScreen();
ForeachExtension<ILoginPageExtension>(ext => ext.OnLoginPageInit(this));
}