如何使文本框文本作为超链接? [英] How can i make a a textbox text as a hyperlink?

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

问题描述

如何使文本框文本作为超链接?
我有一个asp.net文本框用户正在输入他/她的电子邮件
在该文本框中,我想将输入的文本显示为超链接,

How can i make a a textbox text as a hyperlink?
i have a asp.net text box user is enter his/her email
in that textbox i wanted to show the entered text as a hyperlink,
how can i make this possible?

推荐答案

如何使文本框文本作为超链接?
不可能.

HTML内容未在文本框或文本区域中呈现为HTML.为了获得超链接(基本上是您的情况下的href标签),您需要一种Richtextbox控件. Richtextbox控件类型是允许HTML内容并根据需要呈现它的控件.

在此处查看控件:
AjaxToolkit:HTML编辑器 [ jQuery:HTML区域 [ ^ ]
How can i make a a textbox text as a hyperlink?
Not possible.

HTML content is not rendered as HTML in a textbox or a textarea. In order to get a hyperlink (a href tag basically in your case), you need a richtextbox kind of control. Richtextbox type of controls are those control that allows HTML content in it and render it as per you need to.

Have a look at the control here:
AjaxToolkit: HTML Editor[^]
jQuery: HTML Area[^]


[警告!]非常危险!请参见下文.

多亏了d @ nish,我意识到这是非常不安全的,因为这是电子邮件地址. 您不应该这样做.

相反,您应该完全在服务器端处理发送电子邮件(这就是您要执行的操作).您应该创建类似向我发送消息"表单的内容,在表单中发布所有字段,消息文本和文件上传,然后发布此表单.在服务器端,您需要获取所有数据并将其用于从服务器端发送消息.但是,即使这也不应该一对一地完成.恶意艺术家使用的一些简单技巧可以轻松将您的网站变成发送垃圾邮件的僵尸.容易地!技巧之一是以编程方式向您的无辜标题行添加另一个标题行(例如BCC:[百万个地址]),例如Comment.您需要在发送任何内容之前从发布的数据中过滤掉我们的任何违规行为.我还建议您在服务器端进行所有验证(这是讨论的问题,但是对于这样的脆弱问题,例如电子邮件发送会更好).

在我亲自面对这些恶意攻击者之前,我不知道这些恶意攻击者会有多么凶猛.我为其中一个网站(我以前的公司之一)添加了一些恶意攻击统计信息:即使他们发现垃圾邮件并没有被我们的网站重新分发,他们也尝试发送垃圾邮件.同时,对表单的HTTP POST攻击级别始终非常低(如果有的话).

如果遵循这些简单的规则,您将很安全.如果您看到我的联系我"页面,那么您可以找到它的外观.抱歉,我无法显示服务器部分:-)

—SA
[Warning!] Very dangerous! Please see below.

Thanks to d@nish, I realized it is extremely unsafe because this is а e-mail address. You should not do this.

Instead, you should process sending e-mail (it this is what what you want to do) completely on the server side. You should create something like a "Send me a message" form, post all fields, message text and file upload in a form and post this form. On a server side, you need to take all data and use it in sending the message from the server side. However, even this should not be done one-to-one. There are few simple tricks used by malicious artist which can easily turn your site into spam-sending zombie. Easily! On of the tricks is to programmatically add another header line (such as BCC: [million of addresses]) to you innocent header line like Comment. You need to filter our any irregularities from posted data before sending anything. I also advice that you do all the validation on the server side (this is a matter of discussion, but for such a vulnerable issue as e-mail sending would be much better).

I did not know how ferocious those malicious attackers can be until I faced it personally. I added some malicious attack statistics for one of the Web sites, the one of my past company: they attempted to spam even though they could see it is not re-distributed further by our site. At the same time, the level of HTTP POST attacks on the form was always quite low if any at all.

If you follow these simple rules, you will be safe. You can an idea how it looks if you find my Web site if you see my "Contact me" page. Sorry, I cannot show my server part :-)

—SA


除非您对HTML进行模糊处理,否则不建议这样做.如果将简单的href:mailto附加到文本框文本,它将表现为电子邮件链接.虽然如此,僵尸程序或垃圾邮件发送者所使用的任何内容都可以轻松地捕获并使用它.仍然,如果您确实要执行此操作,您所要做的就是检测输入的文本是否是使用RegEx或您选择的其他内容的电子邮件,然后将href:mailto附加到文本中.

当用户离开文本框时,可以通过使用javascript或服务器端代码来完成此操作.我将重复一遍,这将使垃圾邮件发送者的生活变得非常轻松.您可以通过Google搜索混淆器.我从来没有用过,所以不能推荐任何东西. HTH
This isn''t a recommended thing unless you obfuscate the HTML. If you append a simple href:mailto to the textbox text, it will behave as email link. Altough, bots or whatever spammers use can easily catch it and use it. Still if you really want to do this, all you need is detect if the entered text is an email using RegEx or something else of your choice and then append href:mailto to the text.

This can be done both by using javascript or server side code when the user leaves the textbox. I will repeat that this will make spammers'' life very easy. You can search for obfuscators through google. I have never used one so cannot recommend anything. HTH


这篇关于如何使文本框文本作为超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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