how to perform validations in mvc if there is no database attached only ado.net coding is there.
e.g.
if a textbox is empty then no record should inserted and error message appears how to do that
Know the answer? Post it. Somebody with the same question will find it here.
Nilesh ShahRank #42 · 34.2K reputationPosted Jul 31, 2017, 5:52 AM EDT
What you want is input validation, it's irrespective of your code in database side.
Input validation in MVC is super easy, it's done via Required attribute which is placed on top of your class's property (view model class).
This is what you write in view to show validation message:
@Html.ValidationSummary("", new { @class = "text-danger" })
umair mohsinRank #3,092 · 463 reputationPosted Jul 31, 2017, 7:31 AM EDT
Puneet KankarRank #446 · 5.6K reputationPosted Jul 31, 2017, 8:33 AM EDT
Nilesh ShahRank #42 · 34.2K reputationPosted Jul 31, 2017, 8:39 AM EDT
umair mohsinRank #3,092 · 463 reputationPosted Jul 31, 2017, 9:28 AM EDT
Create
Nilesh ShahRank #42 · 34.2K reputationPosted Jul 31, 2017, 10:34 AM EDT
Hi,
and it works fine
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts