MVC PartialView validation on the client

gerrie-govaerts
gerrie-govaerts used Ask the Experts™
on
I have a really annoying MVC problem when I want to validate a partial view that is returned from a controller action.

Depending on a given number, I need to generate a view - it is nicely returned, looks great, and the model is Data Annotated.

Problem: the validation is never triggered on the client and this makes it a real problem.
I have the user to fill in the general information + the details, but the details are not validated.

                        if (ui.index == 2) // test tab
                        {
                            var url = '<%= Url.Content("~/Stock/getTestTab") %>/'+ $("#StockItem_InStock").val();

                            $.get(url, null, function (response)
                            {
                                $("#testcontent").html(response);
                            });
                        }
                    }

Open in new window


Can someone help me please!

Gerrie
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
RobOwner (Aidellio)
Most Valuable Expert 2015

Commented:
Looks like you're using JQuery right? and can you verify that you are getting no response from your ASP script?

Author

Commented:
I certainly get a response but the data annotations (required for example) are not executed on the client - that's the problem
Owner (Aidellio)
Most Valuable Expert 2015
Commented:
I have to say I'm not familiar with MS MVC but I understand it to be a framework and structure to build apps in a way so that the model, view and controller are separate.  Further in web apps the View is the HTML the user sees, the Controller are your ASP scripts that receive the requests from the View and the Model is the backend database, in a simplified .
the Data Annotated model you speak is it a MS SQL database?
I'm sure I can assist as I understand web frameworks and how the technologies interact even though i'm not familiar with MS MVC customisations.

Now...

Can you explain what you mean by the data annotations being executed on the client?? In your original post it says you want them validated...

Author

Commented:
thx
RobOwner (Aidellio)
Most Valuable Expert 2015

Commented:
You've accepted my comment but did you find a solution?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial