ALi Shah

ALi Shah

  • 949
  • 823
  • 784

View Models in asp.net core

Aug 28 2024 5:41 PM

Dear all although its a very simple question and I guess it would be stright but I am facing issue so I am asking on that platform , I am having view model like below 

public class AllModels

{

public class student{get;set;}

public class Grades{Get;set;}

public class Marks{get;set;}

}

ignore the typos if there are any, the issue is I have a view in which I am giving it this model and I only need to use Marks model but on model binding i am giving it complete viewmodel 

@model Allmodels etc 

Now I like to fire validation of only marks model but when i  am saving the records it fire the validation of other two models grades and students as well how to prevent it should I bind my view with only MArks model but I cannot do that as I am using viewModel and on listing i need these other models too and my same view is used for creation as well as for listing.


Answers (1)