简体   繁体   中英

How to get hreflang value in code behind c#

<link rel="alternate" hreflang="zh-cn" /><br />

How to get hreflang value in code behind c#. I tried many ways but still not working.

You can try this way :

<link rel="alternate" id="hrid" hreflang="zh-cn" />

    var v = document.getElementById("hrid").hreflang;

You need to make the <link /> tag a server-side control by adding ID and runat attributes:

<link id="AlternateLink" runat="server" rel="alternate" hreflang="zh-cn" />

You can retrieve the value of the hreflang attribute from your code-behind by using this code:

string hrefLangAttr = AlternateLink.Attributes["hreflang"].ToString();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM