Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. MVC4 Razor @model - what's equivalent in ASPX view engine?

MVC4 Razor @model - what's equivalent in ASPX view engine?

Scheduled Pinned Locked Moved ASP.NET
htmlasp-nettutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Swab Jat
    wrote on last edited by
    #1

    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)

    T 1 Reply Last reply
    0
    • S Swab Jat

      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)

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • T thatraja

        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

        S Offline
        S Offline
        Swab Jat
        wrote on last edited by
        #3

        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%>
        <%} %>

        T 1 Reply Last reply
        0
        • S Swab Jat

          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%>
          <%} %>

          T Offline
          T Offline
          thatraja
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • T thatraja

            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

            S Offline
            S Offline
            Swab Jat
            wrote on last edited by
            #5

            no worries Thatraja, thanks for your help!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups