2

I am using ASP.NET ajax to dynamically add/remove controls from a page without using full postbacks. The UI is very complicated. Under certain scenarios, when a control on the page causes a full postback, after changing the controls via async postbacks, I get this error:

Invalid postback or callback argument. Event validation is enabled using '<pages enableEventValidation="true"/>'

I can fix it by setting EnableEventValidation="false" at the page level.

What are the implications of doing this? Are there times when it is ok to do this or is this a hack?

Community
  • 1
  • 1
brendan
  • 29,308
  • 20
  • 68
  • 109

4 Answers4

4

If you have a WYSIWYG input text box or a textbox expecting HTML, then you have to disable validation or do some JavaScript hack.

The catch is that you will need to provide thorough validation to prevent XSS and such.

oglester
  • 6,605
  • 8
  • 43
  • 63
1

It specifically says on their database tutorial that, currently you have to disable EventValidation. It is a bug. http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/CCDWithDB.aspx

cc.
  • 11
  • 1
1

I would definitely say that it is a hack.

As far as reducing code complexity, have you tried inheriting from some of the controls and putting a lot of your code behind them? This definitely sounds like a case for refactoring!

hmcclungiii
  • 1,765
  • 2
  • 16
  • 27
0

It may not directly answer your question, or seem relevant...

However, if your UI is very complicated, there's probably something wrong with it. Following KISS is a good idea for obvious reasons.

If your UI is complicated, then the chances are you don't understand it, so you'll get more problems, alot of which you may never notice. Your problems and bugs won't be easy to trace or figure out, and are likely to be obscure and removed from the actual cause of the problem.

Secondly, if it's complicated for you, and you wrote it, it's probably incomprehensible for anyone using it. Even if you're just meaning managing the code, the complexity is probably reflected in the presentation.

I suggest you take a look at redesigning the UI so that it isn't so complicated. It will always be better if you look at it again anyway, one doesn't usually have a good solution until the 3rd or 4th attempt at solving the problem.

nicodemus13
  • 2,258
  • 2
  • 19
  • 31
  • 1
    There is an inherent arrogance to this post. The business problem may well require a complicated UI that is not intended for general ease of use, so instead of the lecture, just address the question that was asked. – Bob Jones Jun 11 '12 at 18:04
  • @BobJones: It wasn't intended to be arrogant, and having re-read it, it doesn't seem that way to me. I'm making generally-accepted design points and trying to do so in a helpful way. Although it's *possible* a very complicated design is unavoidable, the vast majority I meet are simply 'designs' that haven't had any real thought put into them. Furthermore, I was under the impression that SO was as much about guiding people as simply answering the bald question the OP may make. And to do it in a manner that avoids being rude, which your comment certainly is. – nicodemus13 Jun 12 '12 at 09:56