8
I am just learning ASP.net MVC so please bear with me if I am bad at explaining my issue.
Is it possible to use a different model in a partial view than what is being inherited in the view?
My view Index currently inherits LoginModel, which deals with the authorization of users. Once a user is authorized, I want the Index to display the list of todos the user has. todos are retrieved via LINQ.
So my partial view wants to inherit System.Web.Mvc.ViewPage<IEnumerable<todo_moble_oauth.Models.todo>>, but I get an error when I use this: `The model item passed into the dictionary is of type
System.Data.Linq.DataQuery`1[todo_moble_oauth.Models.todo]', but this dictionary requires a model item of type 'todo_moble_oauth.Models.LoginModel'
This is my Index view
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<todo_moble_oauth.Models.LoginModel>" %>
<section id="loginForm">
<% if (Request.IsAuthenticated) { %>
<% Html.RenderPartial("_ListTodos"); %>
<% } else { %>
<h1>Todo Mobile</h1>
<blockquote>Easily store your list of todos using this simple mobile application</blockquote>
<% using (Html.BeginForm()) { %>
<%: Html.AntiForgeryToken() %>
<%: Html.ValidationSummary(true) %>
<%: Html.LabelFor(m => m.UserName) %>
<p class="validation"><%: Html.ValidationMessageFor(m => m.UserName) %></p>
<%: Html.TextBoxFor(m => m.UserName) %>
<%: Html.LabelFor(m => m.Password) %>
<p class="validation"><%: Html.ValidationMessageFor(m => m.Password) %></p>