Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Poornima Nayar 94 posts 243 karma points MVP 2x c-trib
    Feb 17, 2016 @ 17:03
    Poornima Nayar
    0

    MVC form

    Hi,

    I have an MVC form which needs to validate well with javaqscript disabled on the browser as well. I am unable to get it working . Has anyone had a scenario like this?

    Any help much appreciated.

    Poornima

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    Feb 17, 2016 @ 17:08
    Dave Woestenborghs
    0

    Hi Poornima,

    You can attribute your request model with some data annotations. Then the validation will also happen server side when you call

    ModelState.IsValid()
    

    in your controller action that handles your post request

    Here is some more information : http://www.asp.net/mvc/overview/older-versions/mvc-music-store/mvc-music-store-part-6

    Dave

  • Frederik Raabye 72 posts 276 karma points MVP 2x c-trib
    Feb 17, 2016 @ 17:09
    Frederik Raabye
    0

    Hello Poornima

    Do you already use DataAnnotations Attributes? If so it should work without scripting enabled. https://msdn.microsoft.com/en-us/library/ee256141(v=vs.100).aspx

    Best regards

    Frederik

  • Poornima Nayar 94 posts 243 karma points MVP 2x c-trib
    Feb 18, 2016 @ 06:59
    Poornima Nayar
    100

    Yes, I had Model.IsValid() and Data Annotations as well. Even then it was not firing. I was rendering my form partial as Html.Partial() as opposed to Html. Action() . I changed that and the server side validations started kicking in. When using Html.Partial() it was validating the model using Model.IsValid() but the validationsummary was not showing up at all.

    Poornima

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    Feb 18, 2016 @ 07:36
    Dave Woestenborghs
    0

    Glad to hear you go it solved. Don't forget to mark this post as a solution so others can find it as well

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies