views:

1049

answers:

5

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:

http://stackoverflow.com/questions/228969/aspnet-invalid-postback-or-callback-argument-event-validation-is-enabled-using

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?

+2  A: 

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.

+1  A: 

@nicodemus13: Good point, when I say the UI is complicated I don't actually mean from a visual perspective.

We're building a query builder for an internal app. On the left is a drop down of all the fields in the DB and on the right is a text box and an "add" button. You can then enter some criteria, click add, and keep building a dynamic query. It's complicated code wise since the end user can basically add and remove controls to the page and when they hit "submit" the state of the page will be different every time.

From the end user POV it is not nearly as complicated.

brendan
+1  A: 

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
+3  A: 

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.

Greg Ogle
+1  A: 

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