strongly-typed-view

Asp.Net MVC - Strongly Typed View with Two Lists of Same Type

心不动则不痛 提交于 2019-12-05 10:59:54
I have a View strongly typed to an Item class. In my controller I need to send two different List. Is there an easier way to do this other than creating a new class with two List. What I am ultimately trying to do is have on my homepage 10 items ordered by Date, and 10 items ordered by Popularity. WHAT I DID I actually went with a combination of the two answers. I strongly-typed my View to the new class I created with the two lists. I then strongly-typed two partial views to the each one of the lists. May seem like overkill, but I like how it turned out. "creating a new class with two Lists"

ASP.NET MVC Strongly Typed Partial View, gives could not load type error

你离开我真会死。 提交于 2019-12-04 16:09:45
问题 I am attempting to create a strongly typed view with a "MVC View User Control" that is being rendered using Html.RenderPartial(). The top of my ascx file looks like this: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Collections.IEnumerable<string>>" %> There is nothing else on this page, currently. When I execute the app and load the page that renders this control, I get the following error: Could not load type 'System.Web.Mvc.ViewUserControl<System.Collections

ASP.NET MVC Strongly Typed Partial View, gives could not load type error

亡梦爱人 提交于 2019-12-03 10:14:13
I am attempting to create a strongly typed view with a "MVC View User Control" that is being rendered using Html.RenderPartial(). The top of my ascx file looks like this: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Collections.IEnumerable<string>>" %> There is nothing else on this page, currently. When I execute the app and load the page that renders this control, I get the following error: Could not load type 'System.Web.Mvc.ViewUserControl<System.Collections.IEnumerable<string>>'. So, then I simplified it: <%@ Control Language="C#" Inherits="System.Web.Mvc

Error when creating a Partial View in Visual Studio 2012 Express with Razor

浪尽此生 提交于 2019-12-01 02:25:25
I am creating a view in Microsoft Visual Studio 2012 Express and I want it to be a strongly-typed partial view, but I am getting the following error: C:\Program Files(x86)\Microsoft Visual Studio 11.0\Common7\IDE\VWDExpress\Item Templates\CSharp\Web\MVC 4\CodeTemplates\AddView\CSHTML\Empty.tt(-1,1) : error : There was a problem getting an AppDomain to run the transformation from the host. The process cannot continue. I have not had any trouble creating views that are not partial views, strongly-typed or not. Is simple... Just restart Visual Studio . http://blog.jongallant.com/2012/07/appdomain

Error when creating a Partial View in Visual Studio 2012 Express with Razor

a 夏天 提交于 2019-11-30 21:57:04
问题 I am creating a view in Microsoft Visual Studio 2012 Express and I want it to be a strongly-typed partial view, but I am getting the following error: C:\Program Files(x86)\Microsoft Visual Studio 11.0\Common7\IDE\VWDExpress\Item Templates\CSharp\Web\MVC 4\CodeTemplates\AddView\CSHTML\Empty.tt(-1,1) : error : There was a problem getting an AppDomain to run the transformation from the host. The process cannot continue. I have not had any trouble creating views that are not partial views,

Custom ViewModel with MVC 2 Strongly Typed HTML Helpers return null object on Create?

≡放荡痞女 提交于 2019-11-30 21:52:05
I am having a trouble while trying to create an entity with a custom view modeled create form. Below is my custom view model for Category Creation form. public class CategoryFormViewModel { public CategoryFormViewModel(Category category, string actionTitle) { Category = category; ActionTitle = actionTitle; } public Category Category { get; private set; } public string ActionTitle { get; private set; } } and this is my user control where the UI is <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CategoryFormViewModel>" %> <h2> <span><%= Html.Encode(Model.ActionTitle) %></span>

Custom ViewModel with MVC 2 Strongly Typed HTML Helpers return null object on Create?

陌路散爱 提交于 2019-11-30 17:53:11
问题 I am having a trouble while trying to create an entity with a custom view modeled create form. Below is my custom view model for Category Creation form. public class CategoryFormViewModel { public CategoryFormViewModel(Category category, string actionTitle) { Category = category; ActionTitle = actionTitle; } public Category Category { get; private set; } public string ActionTitle { get; private set; } } and this is my user control where the UI is <%@ Control Language="C#" Inherits="System.Web

Object reference not set to an instance of an object - Partial View

一曲冷凌霜 提交于 2019-11-29 17:59:55
I have a strongly typed partial view which is giving me "Object reference not set to an instance of an object" error when I launch the master view. I know I am not passing in any parameters yet, but is there a way to handle this error? Master View: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Test Form </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <div id="partial"> <% Html.RenderPartial(

Object reference not set to an instance of an object - Partial View

倾然丶 夕夏残阳落幕 提交于 2019-11-28 12:46:00
问题 I have a strongly typed partial view which is giving me "Object reference not set to an instance of an object" error when I launch the master view. I know I am not passing in any parameters yet, but is there a way to handle this error? Master View: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Test Form </asp:Content> <asp:Content ID=

ASP.NET MVC, strongly typed views, partial view parameters glitch

主宰稳场 提交于 2019-11-27 21:57:40
If i got view which inherits from: System.Web.Mvc.ViewPage<Foo> Where Foo has a property Bar with a type string And view wants to render strongly typed partial view which inherits from: System.Web.Mvc.ViewUserControl<string> like this: Html.RenderPartial("_Bar", Model.Bar);%> Then why it will throw this: The model item passed into the dictionary is of type 'Foo' but this dictionary requires a model item of type 'System.String'. when bar is not initialized? More specific: why it passes Foo, where it should pass null? As @Dennis points out, if the model value is null, it will use the existing