如何插入和显示数据作为链接? [英] How to insert and show data as links?

查看:38
本文介绍了如何插入和显示数据作为链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Web表单,我可以使用文本编辑器将文章插入数据库。我的文章表有以下字段名; id,title,content,type和uploadDate。 'content'字段名由文本组成。此文本还涉及另一个数据库表中的数据,称为标记(即tag_id,名称,类型),它不链接到文章表。



当我查看webform上的文章时,它们看起来像以下输出:

I have created a web form, where I can insert articles to the database, using a text editor. my article table has the following fieldnames; id, title, content, type and uploadDate. The 'content' fieldname is composed of text. This text also involves data from another database table, called tag (i.e. tag_id, name, type), which is not linked to the article table.

when I view the articles on the webform, they look like as the following output:

Pellentesque eget elit tag1. Vivamus ut lacinia lectus. Mauris eu efficitur mi. 
Nam blandit est ut justo scelerisque, in sagittis nibh scelerisque. 
Duis placerat id risus ut aliquam. Vestibulum maximus rutrum arcu et sagittis. tag2 id consequat dui. Suspendisse non imperdiet odio.





我的问题是,如何让我的文章内容看起来像下面所需的输出:



My question, is how can I make my article's content to look like the desired output below:

Pellentesque eget elit tag1. Vivamus ut lacinia lectus. Mauris eu efficitur mi. 
Duis placerat id risus ut aliquam. Vestibulum maximus rutrum arcu et sagittis.  
tag2 id consequat dui. Suspendisse non imperdiet odio.





在文章内容中显示标签的名称作为链接。链接将由某种查询字符串组成,当点击时,它会呈现一个网页,其中包含该标记的id记录(通过DataTable)。



我不是当然,您称之为此功能并且无法通过谷歌找到关于此任务的大量信息,因此我正在寻求一些指导,如何创建此功能。我将如何构建我的数据库表以及实现此任务所需的逻辑(方法)。



任何帮助都将非常感激。非常感谢



Showing, tag's name as links, within the content of the article. The links would be composed of some sort of querystring, when clicked, it renders a to webpage, which holds that tag's id record (via DataTable).

I am not sure, what you call this functionality and was unable to find, much info on this task via google, hence I am seeking some guide, into how to go about creating this functionality. How would i need to structure my database tables and what logic(methods) are required to implement this task.

Any help would be very much appreciated. Many thank

推荐答案

你根本无法为每个对象做到这一点,因为并非每个控件都支持URL。



但是你可以为具有专门用于链接的属性的RTB(RichTextBox)执行此操作。



您可以使用控件的tag属性,即 TreeView.SelectedNode.Tag 并使用 .ToString 将标记转换为字符串并传递该标记的属性: TreeView.SelectedNode.Tag =http://www.google.com 作为RichTextBox的URL链接,将URL显示为链接。



你应该阅读这篇文章了解更多信息和起点。



RichTextBox中包含任意文本的链接
You simply can't do that for every object, as not every control supports URLs.

However you can do this for RTB (RichTextBox) which has a property specifically for links.

What you could do is use the tag property of a control i.e TreeView.SelectedNode.Tag and use the .ToString property to convert the tag to string and pass that tag: TreeView.SelectedNode.Tag = "http://www.google.com" as a URL link to the RichTextBox to display URLs as a link.

You should read this article for more information and a starting point.

Links with arbitrary text in a RichTextBox


这篇关于如何插入和显示数据作为链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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