Depending on where I use my Class, I want to be able to show a different DisplayName.
I have the following class:
[MetadataType(typeof(PortalMetaData))]
[System.Web.Mvc.Bind(Exclude = "PortalId")]
public partial class Portal
{
public Portal()
{
this.Created = DateTime.Now;
}
}
public class PortalMetaData
{
[Requir...
Can I use the MVC 2 DataAnnotations to specify a minimum length for a string field?
Has anyone done this or have they created custom attributes and if so do you mind sharing the source?
...
The field the CheckBox is wired to is nullable.
On my view I get the following error:
Cannot implicitly convert type 'bool?'
to 'bool'
<%= Html.CheckBoxFor(model => model.Product.Exclusive) %>
How do I fix it without having to change the database design?
...
I'm iterating through a collection on my view model. The collection contains HealthLifeDentalRates which implement IBeginsEnds. I have a Display Template BeginsEnds that displays the date range. This results in very slow performance. If I simply the date range (see commented code), it's fine. I think how I'm defining the lambda is the pr...
After the release of MVC 2, i have started to check and play with the new features.
But i couldnt understand that why do i need to use PUT or DELETE verbs ?
I have searched about it and read some articles but i couldnt get it.
What is the main purpose of DELETE and PUT (and do they have any advantages rather than using a GET or POST me...
Hi, I have a .NET 2.0 class the properties of which are marked virtual.I need to use the class as a model in a MVC2 application. So, I have created a .NET 3.5 class inheriting from the .NET 2.0 class and added the DataAnnotations attributes to the overriden properties in the new class. A snippet of what I have done is below
// .NET 2.0 ...
I know that ASP.NET MVC 1.0 is bin-deployable as explained in Phil Haack's article.
Is ASP.NET MVC 2.0 also bin-deployable? Has anyone done this already that can point out potential pitfalls specific to version 2.0 if there are any?
I would like to deploy a relatively simple ASP.NET MVC 2.0 onto a Windows 2008 Web server that does not ...
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;
}
...
I have a large application that currently exists as a hybrid of WebForms and MVC 2.0. Startup of my application is dreadful, and the culprit is primarily because of the AreaRegistration.RegisterAllAreas call. More specifically, that it is using the System.Web. Compilation.BuildManager.GetReferencedAssemblies to enumerate all types in ass...
Hi all
There seems to be an issue with the default model binder when binding to an EntitySet causes the EntitySet to be empty.
The problem is described here and here:
Microsoft's response is:
... We have now fixed this and the fix will be included in .NET Framework 4.0. With the new behavior, if the EntitySet passed into Assign is t...
I have user control in my MVC2 app placed in the Content folder (it's not supposed to be a view, just reusable part of the app).
UserControl1.ascx looks like:
<@ Control AutoEventWireup="true" Language="C#" CodeFile="~/Content/UserControl1.ascx.cs" Inherits="MVCDrill.Content.UserControl1" %>
<div runat="server" id="mydiv">
<asp:LinkBu...
Hi,
I have downloaded the ASP.NET MVC 2 Release version (using Web Platform Installer) as well as the downloading the file directly from the link in WPI. No error messages are reported after the install.
When I go into Visual Web Developer and select Create New project I only the project reference to ASP.NET MVC version 1.0 and not ver...
I want as well as Client Side Validation as Server Side Validation. I realized this as the following:
Model: ( The model has a DataModel(dbml) which contains the Test class )
namespace MyProject.TestProject
{
[MetadataType(typeof(TestMetaData))]
public partial class Test
{
}
public class TestMetaData
{
...
ASP.NET MVC 2 has powerful features for generating the model-dependent content of the Edit view (using EditorForModel) and Details view (using DisplayForModel) that automatically utilizes metadata and editor (or display) templates:
<% using (Html.BeginForm()) {%>
<%= Html.ValidationSummary(true) %>
<fieldset>
<legend><%...
[NOTE: I'm using ASP.NET MVC2 RC2.]
I have URLs like this:
/customers/123/orders/456/items/index
/customers/123/orders/456/items/789/edit
My routing table lists the most-specific routes first, so I've got:
// customers/123/orders/456/items/789/edit
routes.MapRoute(
"item", // Route name
"customers/{customerId}/orders...
With the excellent XVal by Steve Sanderson, it is possible to tell the client side validation to post the value being validated to the server using jquery. A method on the server then uses the same server side code you use for your server side validation, and returns simply a true or false to determine if the field is valid.
The advanta...
If I have a property whose display format is dependent on the value of another property in the view model how do I create a display template for it?
The combination of field1's display being dependent on field2's value will be used throughout the app and I would like to encapsulate this in a MVC 2 display template.
To be more specific...
I'm creating a custom ActionResult class and I need it to be able to operate on a UserControl. All of the examples I've found so far pass in the full path like so:
return MyResult("~/Areas/AreaName/Views/ControllerName/UserControlName.ascx", myModel);
That's pretty long so I'd like it to operate the same way as calling View(), i.e. I ...
Hi,
I am trying to learn Microsoft MVC 2, and have in that case found a small project I wanted to deploy it on.
My idea was to simulate a restaurant where you can order a table.
Basics:
A user can only reserve a full table,
so I don't have the trouble of
merging people on different tables.
A person can order a table for a
certain ...
I am loving ASP.NET MVC, keeping up with the releases/docs can sometimes be tricky, so maybe I'm just not getting something... I want to use a TextBoxFor(), and working with LabelFor() etc. is fine, all the magic happens for me.
But if I create...
<%=Html.TextBoxFor(x => x.LastName) %>
And wanted to do something nice with jQuery, ho...