This is a migrated thread and some comments may be shown as answers.

Editing with a popup and annotated validations.

4 Answers 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Neil
Top achievements
Rank 1
Neil asked on 24 Jun 2011, 05:40 PM

I'm hoping you can help.  In MVC2, I have a view with a grid that is set up with GridEditMode.PopUp and DataBinding with .Update("UpdateAction", "CntrllerNm").  An EditorTemplate is established.  I have a partial class of the model set up with annotations for validation.  The controller is set up like this:

public ActionResult UpdateAction(ModelType myModel)
{
     If (ModelState.IsValid) 
     {
          //Update and Save
          return View(new GridModel(...));
     }
     else
     {
          return View(myModel);
     }
}

If I enter valid values, update, save, and return occur with no trouble.
If I enter invalid values, return View(myModel) fails with an InvalidOperationException stating the view 'UpdateAction' or its master was not found.  The following locations were searched:
~/Views/UpdateAction.aspx
~/Views/UpdateAction.ascx
~/Views/Shared/UpdateAction.aspx
~/Views/Shared/UpdateAction.ascx...

Can someoene tell me what I'm doing wrong?

Thanks

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 27 Jun 2011, 07:26 AM
Hello Neil,

 This is caused by you returning 

return View(myModel);
ASP.NET MVC looks for a view named "UpdateAction" as can be seen from the exception stacktrace.

 You should really be doing 

return View(new GridModel(...));
So the GridAction attribute kicks in and transforms the result. You can check the ajax editing help topic for additional info.
Best wishes,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Neil
Top achievements
Rank 1
answered on 27 Jun 2011, 03:36 PM
Thanks for replying, Atanas.  Yes, new GridModel() will work but I what I was hoping to do was to return the current EditorTemplate popup along with the validation errors.  By doing new GridModel(), will i not be sending back a fresh view, without the validation messages?  I'm not at my office computer so I can't try your suggestion just yet.

Thanks again,

neil
0
Neil
Top achievements
Rank 1
answered on 27 Jun 2011, 05:19 PM
Atanas,

I am back in the office and able to try your suggestion.  It does, in fact, redisplay the popup with the appropriate validation message.  There is only one small behavior oddity...the validation message shows in red and then changes back to black almost immediately.  Strange.

Thanks,

neil
0
Atanas Korchev
Telerik team
answered on 28 Jun 2011, 07:45 AM
Hello Neil,

 Telerik Extensions do not style the validation messages by default. The default styling which comes from Site.css will be used. I am not sure if this behavior is caused by the grid or not. If you want us to investigate that you can send us a sample project which demonstrates this odd behavior.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Neil
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Neil
Top achievements
Rank 1
Share this question
or