Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
CSS
Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Only one 'model' statement is allowed in a file.


Source Error:

Line 4:      ViewBag.Title = "Create"; Line 5:  } Line 6:  @model int Line 7:   Line 8:  @{

Source File: /Views/tblhotelmasters/Create.cshtml Line: 6



@model WebPortal_Planmiles.Models.Data.tblhotelmaster
@{
ViewBag.Title = "Create";
}
@model int
@{
var chk = "checked";
var checked1 = Model == 1 ? chk : null;
var checked2 = Model == 2 ? chk : null;
var checked3 = Model == 3 ? chk : null;
var checked4 = Model == 4 ? chk : null;
var checked5 = Model == 5 ? chk : null;
var htmlField = ViewData.TemplateInfo.HtmlFieldPrefix;
}
Posted
Updated 6-Jun-17 22:56pm
Comments

You have two "@model" statements

C#
@model WebPortal_Planmiles.Models.Data.tblhotelmaster
@model int


you can only have one, exactly as the error message is telling you, so remove one. We don't know which one is the correct one, you'll have to work that out, but it looks like "int" might be correct from the rest of your view code.
 
Share this answer
 
v2
The error could not be more clear! @model can be found twice in your view.

Good luck!
 
Share this answer
 
To add to the other solutions, which are fundamentally correct, if you do indeed want the information from both models (the int and the WebPortal_Planmiles.Models.Data.tblhotelmaster) consider either:

a) Move the int into the viewbag or tempdata

b) Constructing a view model that contains both the WebPortal_Planmiles.Models.Data.tblhotelmaster and an additional integer.

Either way should work for you.
 
Share this answer
 
Just remove one @model statement from your view.
 
Share this answer
 
I had the same problem.
Use @model at the top of your view, where you are declaring your model.
Then instead of typing @model throughout the rest of your view, type @ then use intelisense to select @Model (note the capital M).

Should look something like this:

@model WebPortal_Planmiles.Models.Data.tblhotelmaster
@{
ViewBag.Title = "Create";
}
@Model int
@{
...

NOTE: You must use intelisense. Just simply typing in @Model will not work.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900