This is happening when I try to create the entity using a Create style action in Asp.Net MVC 2.
The POCO has the following properties:
public int Id {get;set;}
[Required]
public string Message {get; set}
On the creation of the entity, the Id is set automatically, so there is no need for it on the Create action.
The ModelState says ...
I use the following code: (returns an excel obviously)
ControllerContext.HttpContext.Response.ContentType = "application/ms-excel";
ControllerContext.HttpContext.Response.Write(sw.ToString());
ControllerContext.HttpContext.Response.End();
return View();
where sw is a StringWriter in which i create my excel structure(a tabl...
Hi,
I'm facing an issue with nested masterpages in Asp.net MVC 2.0.
When using a normal master (not nested - below default.master), the login functionality works fine.
Using the nested master, the ajax form post results in a full page render of the default.master inside the UpdateTarget div. Since in this case the referred master is ...
I'm having trouble adding a validationmessage to my custom editortemplate, this is the line I am using (I've tried posting the entire template code but having no luck)
<%= Html.ValidationMessage(ViewData.ModelMetadata.PropertyName) %>
If I put the validationmessage for the model property outside of the template it works fine so I know...
How can I render a user control in asp.net mvc?
is my only option to use the mvctoolkit?
I am using mvc 2.0 now.
...
Hello everybody!
I am currently developing an application with the new ASP.NET MVC2 framework. Originally I started writing this application in the ASP.NET MVC1 and I'm basically just updating it to MVC2.
My problem here is, that I don't really get the concept of the FormCollection object vs. the old Typed object.
This is my current ...
I upgraded to MVC 2, updated all my assemblies (did copy to local also).
I changed my routes to this:
routes.MapRoute(
"Admin",
"admin/{controller}/{action}/{id}",
new { controller = "Admin", action = "index", id = ""},
new[] { "MyNamespace.Web.Controllers.Admin" } // name...
I'm creating a generic editor for asp.net mvc pages and would like to generate/create urls when I create new items of a specific type. My editor is located under mysite.com/dashboard and I load different models into the same views using the same generic DashboardController. So how can I create urls based on the mapped route or constraint...
My controller has to enumerate all the areas in the application. Is it possible? And how?
...
What is wrong with this ?
<%=Html.DropDownListFor(m=>m.Client,null,"Select",new { @style = "width: 630px" })%>
There is a ViewData["Client"] which contanins the source , the dropdown is filled but is not selected the value corresponding to Model.Client
...
Somebody knows the answer? I'm using L2S with field ntext in my db
...
Is there an Html helper that simply accepts and returns raw html? Rather than do something ugly like this:
<% if (Model.Results.Count > 0) { %><h2>Results</h2><% } %>
I'd like to do something like this:
<% if (Model.Results.Count > 0) { Html.RawHtml("<h2>Results</h2>") } %>
Not a whole lot cleaner, but I think it's a bit of an imp...
Suppose the root project has My.Root.Project namespace. I wonder what namespace should be assigned to an area classes? Possible alternatives:
My.Root.Project.Areas.Area1
My.Root.Project.Area1
Esthetically, I prefer second one.
However, since I use a single-project areas, all the classes created within Areas\Area1\... folder are given...
How do I iterate through all data and copy it to my item?
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
try {
IRepository<ContentItem> repository = ObjectFactory.GetInstance<Repository<ContentItem>>();
var itemId = bindingContext.ValueProvider.GetValue("CurrentItem...
I'm building an asp.net app using themes, and I've assigned a theme to the app using the web config.
I have a bookmark icon that I want to use for my page and it is located in the themes directory, but I am having trouble referencing the themes location from a link tag in my header.
First I tried putting a code block inside the link ta...
I'm building a table of data like this
<% foreach (var person in Model.People)
{
%>
<tr>
<td><%= Html.ActionLink(accessory.Name, "EditPerson") %></td>
<td><%= Html.DisplayFor(c => person.Name) %></td>
<td><%= Html.DisplayFor(c => person.Age) %></td>
<td><%= Html.DisplayFor(c => person.Budget)%></td>
...
In ASP.NET MVC 2, to secure controller action, i have created a class RequirePermission inherited from ActionFilterAttribute class. The controller action looks like
[RequirePermission(permissions="CanView")]
public ActionResult List()
{
...
}
I have an enum with name Permissions
public enum Permissions { CanDoEdit...
Once new area is created by the means of Visual Studio context menu, there are three folders: Controllers, Models, Views. Is it supposed that every area should have it's own model classes? Or is it acceptable/widely-used/good for all areas to share the same model classes in the root Models folder?
My project differs Domain Model and Vi...
I have only tried this in single project areas. So if anyone tries this in a multi-project areas solution please let us know.
Area support was added to MVC2. However the views for your controllers have to be in your main Views folder. The solution I present here will allow you to keep your area specific views in each area. If your proj...
I have an object called Time
public class Time{
public int Hour {get;set;}
public int Minute {get;set;}
public static Time Parse(string timeString){
//reads the ToString()'s previous output and returns a Time object
}
override protected string ToString(){
//puts out something like 14:50 (as in 2:50PM)
}
}...