通过类后面的代码向网页添加超链接 [英] adding hyperlink through code behind class to the webpage

查看:82
本文介绍了通过类后面的代码向网页添加超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<br />
<pre><br />
HyperLink hlRow = new HyperLink();<br />
hlRow.Style.Add("color", "#000000");<br />
hlRow.Style.Add("text-decoration", "none");<br />
</pre><br />


如何让它出现在网页中?
因为我需要执行一个for循环以在执行时向页面添加一些超链接,但是我无法做到这一点,尽管我可以通过C#代码在类后面定义一个超链接,但是当我执行该代码时,网页没有任何显示! !!有人可以帮我吗...


how can i let it appear in the webpage??
because i need to make a for loop to add some hyperlinks to the page while execution, but i couldn''t do that, although i can define a hyperlink through C# code behind class but when i execute the code nothing appears to the webpage !!! could someone help me please...

推荐答案



在您的aspx页面中,首先定义一个容器.

Hi,

In your aspx page define a container first.

<div  runat="server" id="myHyperlink">
</div>



然后从后面的代码中使用像这样添加它



Then use add it like this from code behind

HyperLink hlRow = new HyperLink();
hlRow.NavigateUrl="http://www.google.com";
hlRow.Text = "Google";
hlRow.Visible = true;
hlRow.Style.Add("color", "#000000");
hlRow.Style.Add("text-decoration", "none");

this.myHyperlink.Controls.Add(hlRow);


这篇关于通过类后面的代码向网页添加超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆