Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Validate model on initial request

Validate model on initial request

Scheduled Pinned Locked Moved C#
databasehelp
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nitin_ion
    wrote on last edited by
    #1

    I am returning a model to my view on the initial load of a page, the model is populated from the DB, I want to validate the model so that when the user receives the page a validation summary show the errors if any data in database is coming from ETL system so it can contain invalid data. whole point is to show error on page load to user if any rather than clicking on submit button and then showing errors

    P D 2 Replies Last reply
    0
    • N nitin_ion

      I am returning a model to my view on the initial load of a page, the model is populated from the DB, I want to validate the model so that when the user receives the page a validation summary show the errors if any data in database is coming from ETL system so it can contain invalid data. whole point is to show error on page load to user if any rather than clicking on submit button and then showing errors

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      I didn't see any questions in there.

      N B 2 Replies Last reply
      0
      • P Pete OHanlon

        I didn't see any questions in there.

        N Offline
        N Offline
        nitin_ion
        wrote on last edited by
        #3

        I want to validate model on page load in mvc and show error if any.

        P 1 Reply Last reply
        0
        • N nitin_ion

          I want to validate model on page load in mvc and show error if any.

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          That is a requirement. You still haven't ask a question.

          N 1 Reply Last reply
          0
          • P Pete OHanlon

            That is a requirement. You still haven't ask a question.

            N Offline
            N Offline
            nitin_ion
            wrote on last edited by
            #5

            Q is how to validate model on page load/or on HTTPGet request var uu=TryValidateModel(exceptionData); this always returns true and Model.IsValid return false only on post not on Get

            P 1 Reply Last reply
            0
            • N nitin_ion

              Q is how to validate model on page load/or on HTTPGet request var uu=TryValidateModel(exceptionData); this always returns true and Model.IsValid return false only on post not on Get

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              You have shown no validation code. How can we tell what the actual issue with your code is?

              1 Reply Last reply
              0
              • P Pete OHanlon

                I didn't see any questions in there.

                B Offline
                B Offline
                BobJanova
                wrote on last edited by
                #7

                That's being mean for the sake of it, Pete. The question is clearly 'how do I validate model on initial request?'. There may be issues with that question as your subsequent post points out (there's no code presented and we don't even know what platform is in play), but this post was unhelpful.

                P 1 Reply Last reply
                0
                • B BobJanova

                  That's being mean for the sake of it, Pete. The question is clearly 'how do I validate model on initial request?'. There may be issues with that question as your subsequent post points out (there's no code presented and we don't even know what platform is in play), but this post was unhelpful.

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #8

                  BobJanova wrote:

                  That's being mean for the sake of it, Pete.

                  I'm sorry, but I have to disagree with you there. There is no question in the original post. If I were being mean, I'd have downvoted the post but I didn't. However, my point still stood, there was no question in there. Here's the post:

                  nitin_ion wrote:

                  I am returning a model to my view on the initial load of a page, the model is populated from the DB, I want to validate the model so that when the user receives the page a validation summary show the errors if any data in database is coming from ETL system so it can contain invalid data. whole point is to show error on page load to user if any rather than clicking on submit button and then showing errors

                  That is a requirement, not a question. Of course, I could have made assumptions as to what was supposed to have been asked, but they would have been assumptions. So, it's great that you have the benefit of the subsequent posts to get the context to judge me, but I didn't have that context. All I could see at that point was a request for someone to do the work and not a question on how to solve the problem.

                  B 1 Reply Last reply
                  0
                  • N nitin_ion

                    I am returning a model to my view on the initial load of a page, the model is populated from the DB, I want to validate the model so that when the user receives the page a validation summary show the errors if any data in database is coming from ETL system so it can contain invalid data. whole point is to show error on page load to user if any rather than clicking on submit button and then showing errors

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    OK, so after reading this thread and figuring out (I hope!) what you're really trying to do, my question is WHY?? This is an out-bound model going to the client on a GET request, not a POST. Soooo, I fail to see why you have to validate a model your sending to the client?? If you have to do this, your business rules are messed up because the data in your model should ALWAYS be valid. You normally validate a model in-bound from the client, not out-bound. Yeah, I see the you said your data is coming from an ETL system, so, again, your business logic should be checking this, not your UI code.

                    A guide to posting questions on CodeProject

                    How to debug small programs
                    Dave Kreskowiak

                    1 Reply Last reply
                    0
                    • P Pete OHanlon

                      BobJanova wrote:

                      That's being mean for the sake of it, Pete.

                      I'm sorry, but I have to disagree with you there. There is no question in the original post. If I were being mean, I'd have downvoted the post but I didn't. However, my point still stood, there was no question in there. Here's the post:

                      nitin_ion wrote:

                      I am returning a model to my view on the initial load of a page, the model is populated from the DB, I want to validate the model so that when the user receives the page a validation summary show the errors if any data in database is coming from ETL system so it can contain invalid data. whole point is to show error on page load to user if any rather than clicking on submit button and then showing errors

                      That is a requirement, not a question. Of course, I could have made assumptions as to what was supposed to have been asked, but they would have been assumptions. So, it's great that you have the benefit of the subsequent posts to get the context to judge me, but I didn't have that context. All I could see at that point was a request for someone to do the work and not a question on how to solve the problem.

                      B Offline
                      B Offline
                      BobJanova
                      wrote on last edited by
                      #10

                      It's no less of a question than the one about TIFF and file copying just below. Okay, that one has 'How do I solve this problem?' explicitly, but whenever a thread starter is a description of a problem, that's the implicit question. It might be a bad implicit question, in which case tell the questioner what is wrong with it (or downvote and move on). Anyway, don't mean to start a fight about this but just stating my opinion on dealing with problem descriptions in these forums.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups