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


C# HtmlControls.HtmlLink类代码示例

本文整理汇总了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();
        }
开发者ID:trungjc,项目名称:quanlyhocsinh,代码行数:31,代码来源:PrintHelper.cs

示例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);
            }
        }
开发者ID:rsdgjb,项目名称:GRP_PERFICIENT,代码行数:35,代码来源:ErrorHandler.ashx.cs

示例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();
            }
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:34,代码来源:ClientScriptManager.cs

示例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);
        }
开发者ID:Leonscape,项目名称:ESWCtrls,代码行数:35,代码来源:Util.cs

示例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);
        }
开发者ID:rwoodley,项目名称:FaceToys,代码行数:29,代码来源:Me.aspx.cs

示例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();
        }
开发者ID:abinabrahamanchery,项目名称:mixerp,代码行数:25,代码来源:Default.aspx.cs

示例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);
         }
     }
 }
开发者ID:rcedev,项目名称:evans-software-solutions,代码行数:35,代码来源:Styles.ascx.cs

示例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");
            }
        }
开发者ID:jorik041,项目名称:X.Web,代码行数:33,代码来源:XPage.cs

示例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";
 }
开发者ID:qq358292363,项目名称:showShop,代码行数:7,代码来源:BasePage.cs

示例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());
 }
开发者ID:Refactored,项目名称:SitecoreCalendarModule,代码行数:12,代码来源:PageExtensions.cs

示例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);
        }
开发者ID:charlest704,项目名称:Lad-Solution,代码行数:29,代码来源:AlcoholProof.ascx.cs

示例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);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:PageTheme.cs

示例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;
                }
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:35,代码来源:ResourceExtensions.cs

示例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;
 }
开发者ID:ahaverdings,项目名称:SitecoreFieldSuite,代码行数:7,代码来源:RenderFieldSuiteContentEditor.cs

示例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));
        }
开发者ID:jasper-yeh,项目名称:ClearCanvas,代码行数:28,代码来源:Default.aspx.cs


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