相关文章推荐
彷徨的铁链  ·  java中的 SecureRandom ...·  8 月前    · 
刚毅的海龟  ·  Selenium Python 教程- 知乎·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm creating a client insert form, in this form has a <asp:HiddenField/> named Id for save selected client id, but when I try submit form, it is on Page enableEventValidation="true" error, when I rename this HiddenField for any other Id, it's work

<asp:HiddenField runat="server" ID="Id" />

My form can submit success when I set enableEventValidation="false", but maybe I will need it in future

How to can I resolve this problem? keep HiddenField named Id

PrintScreen:

You've pretty much answered your own question. The only way to make this work is set enableEventValidation="false" or rename your HiddenField

Renaming it would be the best solution here, for security reasons

I've actually created a sample app which has a Hidden field named Id and it doesn't cause any issues. There must be something else causing the issue when combined with this field. – roryok Feb 19, 2014 at 9:25

If you're using framework 4.5 then entry in web.config (requestValidationMode="2.0")

<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" requestValidationMode="2.0"/>
</system.web>

This might not be the solution for your problem, but i was having same problem and solved it by checking for postback before binding data.

  (!IsPostBack)
  binddata(); //this was my gridview binding function
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.