Reputation: 73
I am using ASP.NET MVC 1. I want to pass an int value to from an action to view. I can use 2 ways.
Other these two, Is there a way to pass the int value to view so that I can get the int value using just Model like
<label><%= Model %></label>
Upvotes: 1
Views: 2086
Reputation: 105019
Yes it is. Just define your strong type view like this:
<%@ Page ... Inherits="System.Web.Mvc.ViewPage<int>" %>
Upvotes: 1
Reputation: 13083
This works just fine with MVC 2. Don't really know the reason why would you stick with MVC 1. And I also couldn't test it out in MVC1 so I cannot guarantee that it works there.
public ActionResult Five()
{
int five = 5;
return View(five);
}
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<int>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Five</h2>
<%: Model %>
</asp:Content>
Upvotes: 6