2

I have 2 buttons that I want to redirect to the other view with different model. So I have a table and above, there are 2 buttons.

So I have this current code in my view

 <div class="form-horizontal">
      <input type="button" value="Create Item" class="btn btn-primary"
         onclick="location.href='@Url.Action("CreateItem", "Home")';return false;" />

      <input type="button" value="Create Records" class="btn btn-primary"
         onclick="location.href='@Url.Action("CreateRecords", "Home")';return false;" />
 <div>

The first button or input type is working. Because the current view and the CreateItem have the same model which is:

 @model MyModel.Jobs.Web.Library.Doman.Item

But my 2nd input type has different model which has CreateRecords Action is:

 @model MyModel.Jobs.Web.Library.Domain.Records

So it throws me an error that is System.InvalidOeprationException. How do I fix this? Thanks!

Big. D
  • 31
  • 1
  • 7

0 Answers0