如何在.aspx C#中将href分配给锚标记 [英] How to assign href to anchor tag in .aspx C#
本文介绍了如何在.aspx C#中将href分配给锚标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
aspx页面: -
< p class = l > 版权所有 & copy; 2016 - < a href = www.Test。 com > 测试< / a > & middot; 保留所有权利。< / p >
href =www.Test.com
点击测试链接我得到这样的东西: - localhost / www.Test.com
您知道任何解决方案吗?
解决方案
也添加协议。< br $> b $ b
< a href =http://www.Test.com>
你必须输入完整的地址,从http://
< a href = http://www.Test.com > 测试< / a >
来自代码:
添加Id
属性和运行at =server
到锚标记为
< < span class =code-leadattribute> a id = anchorID runat = server > 测试< / a < span class =code-keyword>>
和href
可以在后面的代码中分配为
anchorID.Attributes [ href] = http://www.Test.com;
aspx page:-
<p class="l">Copyright © 2016 - <a href="www.Test.com">Test</a> · All Rights Reserved.</p>
href="www.Test.com"
click on Test link and I got something like this :- localhost/www.Test.com
Do you know any solutions?
解决方案
Add the protocol also.
<a href="http://www.Test.com">
you will have to type the full address starts fromhttp://
<a href="http://www.Test.com">Test</a>
from code behind:
add anId
attribute andrunat="server"
to the anchor tag as
<a id="anchorID" runat="server">Test</a>
and thehref
can be assigned in code behind as
anchorID.Attributes["href"] = "http://www.Test.com";
这篇关于如何在.aspx C#中将href分配给锚标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文