How to allow apostrophe in asp.net website

2019-07-01 15:05发布

In my asp.net website I create user with their details, If suppose the surname of the user is Sam's then when I edit the user the display in the text box is Sam's but in database it is stored as Sam's, and When I just try to update name as Sam's then i get the error below, How should I show the name in the text box txt_EditLastName.Text = gvrow.Cells[2].Text;

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

2条回答
相关推荐>>
2楼-- · 2019-07-01 15:45

I used a find and replace of ' with `

' - Apostrophe
` - Grave Accent

The Grave accent looks the same and can be stored in SQL databases without messing them up. The grave accent is usually found above the Tab button on your keyboard, to the left of the numbers.

Hope this helps.

查看更多
看我几分像从前
3楼-- · 2019-07-01 15:51

I got this error because Visual Studio 2010 added a little bit of security. To work around it you need to add ValidateRequest="false" to the page directive or add <pages validateRequest="false" /> in the web.config file. 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.

This link will help. http://www.cryer.co.uk/brian/mswinswdev/ms_vbnet_server_error_potentially_dangerous.htm

查看更多
登录 后发表回答