[英]Dynamically created href attributes in C#
This is the C# code used to create a link to google 这是用于创建到Google的链接的C#代码
href.Controls.Add(Image);
href.Attributes.Add("href", "www.google.com");
href.Attributes.Add("target", "_blank");
href.Attributes.Add("title", "Click To Follow The Link");
however when I click it, the url it takes me to is this 但是,当我单击它时,它带我到的网址是
http://localhost:52647/Mywebsite/www.google.co.za
any ideas on how I make it go straight to google? 关于如何使它直接进入Google的任何想法?
Try prefixing it with http:// 尝试使用http://作为前缀
href.Controls.Add(Image);
href.Attributes.Add("href", "http://www.google.com");
href.Attributes.Add("target", "_blank");
href.Attributes.Add("title", "Click To Follow The Link");
change href.Attributes.Add("href", "www.google.com"); 更改href.Attributes.Add(“ href”,“ www.google.com”); to href.Attributes.Add("href", " http://www.google.com ");
到href.Attributes.Add(“ href”,“ http://www.google.com ”);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.