MVC4 Razor @model - what's equivalent in ASPX view engine?
-
hi MVC4 Razor @model - what's equivalent in ASPX view engine? Here's how it's done with Razor - how to do the same in ASPX? @model IEnumerable @{ ViewBag.Title = "Downloads"; Layout = "~/Views/Shared/_Layout.cshtml"; }
@foreach (var Package in Model) { }
Name
Description
@Html.DisplayFor(modelItem => Package.Name)
@Html.DisplayFor(modelItem => Package.Description)
@Html.ActionLink("Download", "ProductDownload", Package)
-
hi MVC4 Razor @model - what's equivalent in ASPX view engine? Here's how it's done with Razor - how to do the same in ASPX? @model IEnumerable @{ ViewBag.Title = "Downloads"; Layout = "~/Views/Shared/_Layout.cshtml"; }
@foreach (var Package in Model) { }
Name
Description
@Html.DisplayFor(modelItem => Package.Name)
@Html.DisplayFor(modelItem => Package.Description)
@Html.ActionLink("Download", "ProductDownload", Package)
Try like this
<%@ Inherits="IEnumerable<XYZ.Product>" %>
If still not clear, create a blank MVC Internet application & check Register/Login/ChangePassword pages. Take a look at the first line there. FYI ASP.NET MVC 4 - Part [3] - Razor View Engine and ASPX View Engine[^] But go with Razor Razor is Better. Seriously Better[^]
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
-
Try like this
<%@ Inherits="IEnumerable<XYZ.Product>" %>
If still not clear, create a blank MVC Internet application & check Register/Login/ChangePassword pages. Take a look at the first line there. FYI ASP.NET MVC 4 - Part [3] - Razor View Engine and ASPX View Engine[^] But go with Razor Razor is Better. Seriously Better[^]
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
Thankyou Thatraja! Question, with ASPX you declare your "Model" as such: <% Inherits="IList" %> Do you still use "Model" keyword when enumerating items from server side script, from "foreach"?
<%foreach (var Product in Model) { %>* <%=Product.Price%>
<%} %> -
Thankyou Thatraja! Question, with ASPX you declare your "Model" as such: <% Inherits="IList" %> Do you still use "Model" keyword when enumerating items from server side script, from "foreach"?
<%foreach (var Product in Model) { %>* <%=Product.Price%>
<%} %>Sorry to disappoint you, I don't use ASPX view as I'm happy with Razor & don't like ASPX view. What happened when you tried that? Always include error message in your message. Again I'm telling you, go with Razor. It has many advantages, see my previous message.
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
-
Sorry to disappoint you, I don't use ASPX view as I'm happy with Razor & don't like ASPX view. What happened when you tried that? Always include error message in your message. Again I'm telling you, go with Razor. It has many advantages, see my previous message.
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute