This was the push I needed in the right direction! The jquery validate function did the trick. The form was loaded with jquery and after submitting the validation wasn't correctly handled – Rob Apr 22 '10 at 9:58.
While xVal is a good way to make the application user friendly, you still HAVE to do server side validation. If you don't validate your data on the server - you have a masive security hole! Try checking if the ModelState.
IsValid in your controller before saving the values. Now, from what I see you're registering the xVal validation using ("Product") %> The way it works is it enables client side validation for all controls prefixed with "Product". Your textbox on the other hand has an id of FromPriceInCents So the solution here would be to do this: () %> UPD3 I updated the post.
Fixed the code so that the prefix is not used. Also, I compiled a working solution that contains a working solution. List, Edit, Create page, string and int properties, and xVal validation.
Public class Product { ScaffoldColumn(false) public int Id { get; set; } Required Range(1,50) public int PriceInCents { get; set; } Required StringLength(50) public string Name { get; set; } } and on the view model. PriceInCents) %> model. PriceInCents) %> Here's the download link.. Check it out and tell me if it works http://www.flexlabs.org/download/xValTest.
Thanks for the good response, i'll try your solution and let you know. You're right about the server side validation, I indeed still need to fix this. – Rob Apr 19 '10 at 6:55 I tried your solution by adding the prefix to the textbox.
But then the validation doesn't work at all. When I use it like this; ("product") %> The validation is showing me errors when I enter text in a box expecting numbers. But when I try to submit the page it is still doing a postback, something which I don't expect and want it to do.
Got serverside validation working now with Modelstate. IsValid – Rob Apr 19 '10 at 7:40 Ah yes, that's because the Create method could not puck up the values from the form values.. I updated the post with an example – Artiom Chilaru Apr 19 '10 at 8:26 @Artion thanks for the quick response, I tried both your suggestion but it doesn't work :( I found out that where using a button to submit the form, so I updated the question with it. Could this have something to do with the issue?
– Rob Apr 19 '10 at 8:55 1 Updated the post with a more correct example + an example project download.. definitely working :) – Artiom Chilaru Apr 19 '107 at 20:43.
With the properties you have specified as long as anything is entered in the textbox it should pass client side validation.
The range attribute is an an test. But i'll try putting it back on and see what happens. – Rob Apr 16 '10 at 14:31 OK I tried it, the client side validation is giving this error; Please enter a value between 1 and 2147483647.
But in firebug I can see the page is still trying to do an postback, but it returns the error below; 'Object reference not set to an instance of an object. ' – Rob Apr 16 '10 at 14:35 Try having your Create action take the object type like this public ActionResult Create(ObjectType newObject) – Mnton Apr 16 '10 at 16:24 The controller is already taking the following parameters public override ActionResult Create(Guid pageId, Guid pluginInstanceId, Product entity, FormCollection collection) – Rob Apr 16 '10 at 7:46.
While xVal is a good way to make the application user friendly, you still HAVE to do server side validation. If you don't validate your data on the server - you have a masive security hole! Try checking if the ModelState.
IsValid in your controller before saving the values.
While xVal is a good way to make the application user friendly, you still HAVE to do server side validation. If you don't validate your data on the server - you have a masive security hole! Try checking if the ModelState.
IsValid in your controller before saving the values. The way it works is it enables client side validation for all controls prefixed with "Product". I updated the post.
Fixed the code so that the prefix is not used. Also, I compiled a working solution that contains a working solution. List, Edit, Create page, string and int properties, and xVal validation.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.