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