JQuery UI button triggering “potentially dangerous

2019-07-15 05:52发布

I have begin testing my application with IE and have found that buttons that are styled using JQuery UI button are posting their entire content to the server. This means that they post a span with the text inside it. This triggers a "A potentially dangerous Request.Form value was detected from the client" error in ASP.Net. This does not happen with <input type=Submit /> but does with Button elements. However I have button elements which trigger JavaScript and so should not be set up as <input type=Submit />.

How do I fix this? It seems that it must be common enough that there is a widely accepted solution but I haven't been able to find anything by searching.

2条回答
smile是对你的礼貌
2楼-- · 2019-07-15 06:39

Per your success: Removing the button name attribute solves the problem.

查看更多
三岁会撩人
3楼-- · 2019-07-15 06:40

I would take the type="submit" and change it to type="button" and then add the submit in the script after you do the other stuff needed.

<button type='button' id='mybutton'/>

$('#mybutton').click(function(){
   // do my stuff here with submit last
});
查看更多
登录 后发表回答