resthere
resthere

Reputation: 129

The @model directive in view does not bind the View model

The application is .Net Framework 3.5 and MVC Framework 1.0 The controller has:

namespace MockBDPWorkflowTestApp.Controllers
{
    public class WorkFlowTestController : Controller
    {
        //
        // GET: /WorkFlowTest/

        public ActionResult OpenSubmission(string processId, string mailId)
        {
            var SubmissionModelView = new MockBDPWorkflowTestApp.ViewModels.WorkFlowTestViewModel{processInstance =processId,  mail =mailId} ;
            return View("Submission", SubmissionModelView);
        }
    }
}

The View Model has

namespace MockBDPWorkflowTestApp.ViewModels
   {
    public class WorkFlowTestViewModel
    {
        public string processInstance { get; set; }
        public string mail { get; set; }
    }
   }

The view has:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
@model MockBDPWorkflowTestApp.ViewModels.WorkFlowTestViewModel
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

The model directive is not recognized and @Model. does not give the option processInstance and mail

What am I missing , the bind to view is not happening. Please can some one help.

Upvotes: 0

Views: 332

Answers (1)

Pricey
Pricey

Reputation: 5929

I think @model is for the Razor views, but it looks like you might be using it in an .aspx page view.

You should instead try supplying the type like this:

Inherits="System.Web.Mvc.ViewPage<MockBDPWorkflowTestApp.ViewModels.WorkFlowTestViewModel>

see if that works.

Upvotes: 2

Related Questions