简体   繁体   English

如何在asp.net网站上允许撇号

[英]How to allow apostrophe in asp.net website

在我的asp.net网站上,我用他们的详细信息创建用户。如果假设用户的姓氏是Sam's那么当我编辑用户时,文本框中的显示是Sam's但是在数据库中它被存储为Sam的,并且当我只是尝试将名称更新为Sam时,我得到下面的错误,我应该如何在文本框中显示名称txt_EditLastName.Text = gvrow.Cells[2].Text;

A potentially dangerous Request.Form value was detected from the client (ctl00$MainContent$txt_EditLastName="Sam's").

I got this error because Visual Studio 2010 added a little bit of security. 我收到此错误是因为Visual Studio 2010增加了一些安全性。 To work around it you need to add ValidateRequest="false" to the page directive or add <pages validateRequest="false" /> in the web.config file. 要解决此问题,您需要将ValidateRequest="false"添加到页面指令中,或者在web.config文件中添加<pages validateRequest="false" /> I put it in the wrong spot at first, so make sure you put that in the <system.web> area of your web.config file. 我首先将它放在错误的位置,因此请确保将其放在web.config文件的<system.web>区域中。

This link will help. 这个链接会有所帮助。 http://www.cryer.co.uk/brian/mswinswdev/ms_vbnet_server_error_potentially_dangerous.htm http://www.cryer.co.uk/brian/mswinswdev/ms_vbnet_server_error_potentially_dangerous.htm

I used a find and replace of ' with ` 我使用了'with`的查找和替换

' - Apostrophe
` - Grave Accent

The Grave accent looks the same and can be stored in SQL databases without messing them up. Grave重音看起来相同,可以存储在SQL数据库中而不会弄乱它们。 The grave accent is usually found above the Tab button on your keyboard, to the left of the numbers. 重音通常位于键盘上的Tab键上方,位于数字的左侧。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM