strongly-typed-view

VB Syntax to declare a single model in MVC (to leverage strongly typed views)

I'm trying to avoid the use of magic strings as much as I can, but I can't find the correct syntax for VB to bind a single model like is shown in this c# example. Can anyone point me in the right direction? (currently the below says "expected end of statement" under the Model text) <% Dim FormObject As Form = (Form)Model %> EDIT: A...

How to bind an Html.DropDownList without ViewData (Strongly-Typed View)

I can't seem to find a good blog post that shows how to bind a model to a view without the magic strings "ViewData" (using a strongly-typed view is the approach I'm trying to take) Does anyone know what I need to alter in the below to bind this directly to my model? View <%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Maste...

When would you not use a strongly-typed ASP.NET MVC view?

Assuming that an ASP.NET MVC View is going to show data, is there any scenario where you would not want to use a strongly-typed view? ...

Name 'Model' is not declared in a strongly typed view - ASPNET MVC

As of recent, a few of my strongly typed views randomly (w/ zero code changes) decided that 'Model' was not a valid item ... again - ZERO code changes. I simply opened my view and now it's broken ... so logically I deleted the view and created a new one - still broken. Has anyone else come across this issue using MVC? A simple example...

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

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...

setting page title when using strongly typed view data in asp.net mvc

Hi, How can I set the page title in asp.net mvc using strongly typed views AND a master page. I added a public property to my master page class, but can't seem to get access to it in my view/action. ...

How do I bind a textbox to a Model parameter in a Strongly Typed View in Asp.Net MVC?

The only way I've seen this done in the tutorials I've looked at, they say to create a new .ascx and choose the option "create" for View Content. I want to be able to customize mine more with specific ID's... So, if I have a Customer that has data: string FirstName, string LastName, string Address. How can I bind my textboxes so that wh...

ASP.NET MVC Newbie: why isn't my model available when creating a strongly-typed view?

I'm starting with ASP.NET MVC, and working with NerdDinner as reference. I did the following: Created a new project Added a couple of tables Created LINQ to SQL for them Created a new controller My Models directory now contains MyModel.dbml, under which I have MyModel.designer.cs, that contains classes for models relating to both of...

Is right use strongly-typed partial views?

Hello, everybody. I'm developing a little application in ASP.NET MVC. This app has a lot of "HTML pieces" that are used many times with a little variance. For this pieces, I'm using strongly-typed partial views. My question is: This is the right way to reuse code in View layer? Is there some inconviniece to use partials views? Thank...

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

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...

ASP.NET StrongTyped Controller-Action View<TView,TModel>(TModel Data)

I'm using Asp.net MVC 1 and I would really like my controller actions to use StronglyTyped View(data) calls that enforce type checking at compile time and still let me use aspx pages under the default view engine. The ViewPages I call are strongly typed, but errors in the action's call to View(data) can't be caught at compile time becau...

ASP.NET MVC Strongly Typed View for class that has a collection of objects

Consider this scenario: class Book { int id; List<Category> categories; } class Category { int id; string name; } I have a strongly typed view for the class Book. When the librarian wants to edit the details of any Book, I want to display checkboxes with all possible categories. In case Book.categories contains a cate...

object Model types in MVC2 using strongly typed view pages problem.

I have a new converted MVC2 project running against the MVC2 source code. I have done this conversation twice on the same solution. I use strongly typed views on every page of the site and so far I haven't had any issues running against the source nor developing with strongly typed views. Now on one strongly typed view in particular t...

ASP.NET MVC List population in strongly typed views

A bit of background: I'm building an MVC app to store golf course data and have created a Create view page for the courses. This contains a partial view of a scorecard that I am going to use for other things such as recording results etc. I've currently built the scorecard so it fires off jquery triggers when it is edited. From which t...

Strongly typed views in NHaml?

I have a strongly typed view and want to use it in an NHaml page. With the WebForms engine I would describe the ViewData type in the <%@ Page%> directive or in the codebehind file. How would I go about that in NHaml? ...

Best way to save data on a strongly-typed view when not all fields are loaded

Let's say I have an edit view that is strongly-typed to a table called "MyData". The view has multiple tabs, each with several different fields from the table. For performance, the data is only loaded when the tab is viewed, so if you only edit a field on tab 1 and submit the form, the data for tab 2 will not be loaded. The problem I'm ...

Can you use MVC 2 Strongly Typed Helpers in Partial View?

I'm trying to use the new strongly typed helpers. I've inherited the Model in my Control: Inherits="System.Web.Mvc.ViewUserControl" but intellisense isn't exposing the model and the page isn't happy with it if I force the code in. If I do it in a standard View all is good. This is what I'm expecting to be able to do: <%= Html.LabelFor...

MVC strong type view not returning values

Hi: I am using MVC and have created a strongly type model to post data to a page. The data combines and address and company information. I set the address ID and Company ID in the model information and send it to the view. The view may or may not display the ID's. When the form is submited the ID values the are not valid. get and d...

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

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 ...

How can I use a prefix for the fields in my strongly typed View?

Hi, I have an EditProfile action in my PersonController, that finds a Person object by ID and does return View(person). The EditProfile view has a bunch of fields that should be filled in with the information from the Person object. One of the fields is named "Person.FirstName", and is not filled in automatically when the View is rende...