链接到Textarea ....... [英] Link in Textarea.......
问题描述
我有一个文本区域.该textarea正在从数据库中获取一些记录.该数据还包含一些超链接,并且应该是可单击的,例如,我的文本如下.
Hi,
I have a textarea. This textarea is getting some records from the database. The data also contains some hyperlinks and it should be clickable, say for example i am having a text as below.
To download the content, click here.
现在,单击此处是单击时重定向到另一个站点的超链接.
现在,此链接在我的文本区域中未显示为超级链接.
而是在我的文本区域中,其显示为纯文本,而没有实际的超链接.
如何使单击此处文本显示为我的文本区域中的超链接.
问候,
Now click here is a hyperlink redirecting to another site when clicked.
now this this link is not appearing as a hyper link in my textarea.
Instead of that it is appearing as a plain text in my text area without the actual hyperlink.
How it is possible to get click here text to appear as hyprerlink in my textarea.
Regards,
推荐答案
您好,Pranavcool,
很抱歉,您将无法在文本区域中显示可点击的超链接.如果您的用户不需要使用textarea编辑数据的功能,则可以使用Literal或仅使用Response.Write().如果他们确实需要编辑,则应考虑用HTML替换文本区域,并包括属性contenteditable ="true".然后,您可以使用jscript将innerHTML写入与表单一起提交的隐藏输入中(例如).在将输入服务器端提交到数据库之前,请仔细验证输入服务器端,用户(可能由于XSS漏洞而在不知不觉中)可以将任何来源的HTML粘贴到div中.
Hi Pranavcool,
I'm sorry, you won't be able to display a clickable hyperlink in a textarea. If your users don't need the ability to edit the data with the textarea, you could use a Literal instead or just Response.Write(). If they do need to edit, you should consider replacing the textarea with an Html Div and include the attribute contenteditable="true". You could then use jscript to write the innerHTML to a hidden input that submits with your form (for example). Carefully validate the input server-side before committing it to your database, the user (perhaps unknowingly due to a XSS exploit) could paste HTML from any source into the div.
<div style="border: thin inset #C0C0C0; height: 130px; width: 423px" contenteditable="true">
Search with <a href="http://www.bing.com/">bing</a>?
</div>
这篇关于链接到Textarea .......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!