超链接存储在带有一些文本的记录中 [英] Hyperlink stored in a record with some text

查看:82
本文介绍了超链接存储在带有一些文本的记录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网页中,我的编码类似于

In a web page, I coded like that

<p class="h3" style="margin-top: 0px;">
   Welcome to xxx. From here you can link directly to
    <asp:HyperLink ID="HyperLink1" Text="Metroview"

        NavigateUrl="http://yahoo.com" Target="_blank"

        runat="server"></asp:HyperLink>
   , and you can ....
 </p>



现在,我想存储文本(包括超链接)到数据表。怎么做到呢?谢谢。


Now, I want to store the text (including the hyperlink) into a data table. How can it be done? Thanks.

推荐答案

您好,



是的,简单,

你可以使用此代码获取NavigateUrl的值,如下所示

在C#中,

Hi,

Yes its simple,
You can use this code to get the value of NavigateUrl like this
In C#,
string attributeValue = HyperLink1.Attributes["NavigateUrl"];



HyperLink1 - >要读取属性的控件的ID

NavigateUrl - >您想要阅读的属性名称



更新的解决方案,

如果这是您的要求,则将attributeValue存储在DB中。 br />
然后显示添加这样的



Aspx代码


HyperLink1 --> ID of the control that you want to read the attribute
NavigateUrl --> Attribute name that you want to read

Updated solution,
if that is your requirement then store the attributeValue as it is in DB.
Then while displaying add like this

Aspx code

<asp:HyperLink ID="HyperLinkID" Text="Displaying link from DB" runat="server"></asp:HyperLink>



C# :


C#:

HyperLinkID.Attributes.Add("NavigateUrl",attributeValueFromDB);



现在,当显示HyperLink时,将填充navigateURL f rom Db if attributeValueFromDB有DB值(http://yahoo.com)

希望这会对你有所帮助。



问候,

RK


Now while displaying the HyperLink will have navigateURL populated from Db if attributeValueFromDB has DB value("http://yahoo.com")
Hope this helps you a bit.

Regards,
RK


这篇关于超链接存储在带有一些文本的记录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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