views:

60

answers:

2

When a user tries to click:

       Save

and they have entered in some invalid data, i want to notify them. This can be with methods such as:

  • directing their attention to the thing that needs their attention with a balloon hint
  • automatically dropping down a combo-box
  • triggering an animation
  • showing a modal dialog box
  • etc

What is the mechanism where a controller tells the view to show a validation message for some controls, given that different views have different notification methods?

p.s. the controller doesn't know the order that controls are physically arranged in the view (e.g. LTR locale wants to notify the user in a top-down-left-to-right visual order, while RTL locale wants to notify the user in a bottom-up-right-to-left order)

+1  A: 

The controller can add a Validation object to the Model, which can contain the names of the fields which were invalid, specific validation messages, etc.

The View can then choose to render this Validation object however it wishes: by highlighting the incorrect fields, animating something, showing a modal dialog, etc.

matt b
+1  A: 

If you are using ASP.Net MVC 2.0, check out this post by Scott Gu, although some of this will apply for ASP.Net MVC 1.0 as well.

Thanks

Mahesh Velaga