asp.net-mvc-2

Validation in ASP.NET MVC using Code Contracts

I want to know the available options for using the "Code Contracts" attributes as the validations rules in ASP.NET MVC 2. ...

MVC Validation Summary groups

How to extend HTM.ValidationSummary to support validation groups? ...

Generate Database / Entity Data Model from C# Classes

I have been using Subsonic with MVC.NET and love the feature that allows me to generate a database from the c# classes. This is great because it allows you to think about the app first and the data second. Now that I am moving onto MVC.NET 2.0 - I am using the features in the Entity Framework which are great giving form validation clien...

UrlHelper extension method not working

I'm trying to add an extension method to my MVC 2 project without success and after several hours of googling and looking here I'm at a loss. I've created a brand new MVC 2 project to make sure there was not anything weird about my existing project and I'm still facing the same problem. I'm sure this is a situation of I "can't see the ...

public definition of GetEnumerator in asp.net mvc missing?

Should I manually create a definition for GetEnumerator? Seems like it should know... I get the following error: foreach statement cannot operate on variables of type 'MvcAppNorthwind.Models.Product' because 'MvcAppNorthwind.Models.Product' does not contain a public definition for 'GetEnumerator' Line 9: <h2><%: ...

How to display data from several models in the same view?

I have a Product Model from the database which I display on the View, but if I also wanted to display Categories also and so forth. How to do that? <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcAppNorthwind.Models.Product>>" %> But if you want to display or use data...

Is it possible to use <%: in .net framework 3.5

This may be a duplicate of some other question, but it's hard to search the web for <%: so I can't really find anything. When I created a new Asp.net MVC 2 project its templates use the new notation of automatic html encoding. WHen I changed .net framework target to 3.5, these server scripts stopped working. When I changed them to <%= e...

Linq query to get results from DB in ASP.NET MVC 2

How do I query using Ling to Entities. I want to get back the total number of rows for a specific user. I created a table with an ID(PK), Username, and PhoneNumber. In my controller, I am able to do this and see my entities: public ActionResult UserInfo() { using (UserInfoEntities db = new UserInfoEntities()) ...

Html.ActionLink and HTML as parameter (ASP.Net MVC 2)

Html.ActionLink("<span class=\"title\">Retry</span><span class=\"arrow\"></span>", "Login", "User") Hi, If I execute above code in ASP.Net MVC 2, I get the following output on my screen: How do I disable the escaping of the code, so my span is within the ActionLink, and not displayed as output? I know this is expected behavior, to ...

Entity Framework persistence problem giving "The ObjectStateManager does not contain an ObjectStateEntry with a reference to an object of type.."

In the database I have have: PK CountryID int notnull PK ServiceID int notnull PK TaskID int notnull PK TaskItemID int notnull PK CorrespondentID int notnull PK PreviousTask int notnull IsOnTimeline bit not null ..and 5 other nullable fields I am using this composite key to ensure uniqueness of the "ServiceSchedule" item. The "P...

Accessing the ActionExecutingContext using a helper class

I have been struggling with this for the past few hours. All I'm trying to do is pick action parameters from the current route like this. This method resides inside a simple static helper class. public static string GetStateName(ActionExecutingContext filterContext) { var stateParam = filterContext.ActionParameters.Wher...

MVC 2 viewmodels question

Just working through a tutorial on asp.net/mvc for the music store application. Ref: http://www.asp.net/mvc/tutorials/mvc-music-store-part-3 In the controller they are passing a list of genres to the view model, I am just a beginner but I feel like it is the viewmodel's job to present the data in what ever format the view requires. th...

jQuery $.ajax works first time, but not on subsequent clicks

Everything works fine on the first click of the delete link, but subsequent clicks only delete the record, without refreshing the "quotes" div. I'm not sure what I'm overlooking here. My .js file: $('.deleteRow').live('click', function (e) { if (confirm('Delete?')) { $.ajax({ type: 'POST', url: this...

How should I work around an ASP.Net MVC Route mapping conflict?

I have two routes mapped in my MVC application: public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Project", "{controller}/{projectid}/{action}/{id}", new { ...

asp.net mvc business form templates

Hi, i'm looking for asp.net mvc business form templates. Nothing special just simple grid(delete, edit, create, etc), create new user, edit info, show statistic and so on. Any suggestion? ...

How to implement like-HtmlHelper

HtmlHelpers are really useful, also i was using AjaxHelpers untill i wanted to do something they can't... so now i'm prefering jquery+javascript, but i don't like to write in javascript (mayby because i never know it as good as i wanted) and to make life easier i wanted to implement something like JQueryHelper, but right now i don't know...

asp.net mvc dropdown problem

hi, i am getting error after post, when i am using dropdown in my mvc website, the code is as follows ViewData["JobSite_JobCategories1"] = new SelectList(context.JobSite_JobCategories, "Id", "Category", null); <%= Html.DropDownList("JobCategory", ((IEnumerable<SelectListItem>)ViewData["JobSite_JobCategories1"]))%> <%= Html.ValidationM...

Organize simple form

Hello, I want to create a simple page. Page has table with some product information(id,Name,Order, Size etc), page listener, filter form(products from date1 to date2, products size...). what is best way to organize such pages? Also i want to use ajax, but it's not necessary. My vision: PageListener<T> class with method List<t> GetPage...

How can I create links for my website?

Hi guys! I'm trying to make a little side-bar menu so people can access area of the web application. Here is what I have so far: <ul id="navi"> <li><img src="../../Content/inicio.png" alt="Inicio" /></a></li> <li><img src="../../Content/evaluaciones.png" alt="Evaluaciones" /></a></li> <l...

How can I get the total number of items in a SQL result?

I have the following code: [code] <h2>Listado General de Carreras</h2> <% foreach (var item in Model) { %> <p><span class="titulo"><%=Html.ActionLink(item.Nombre, "Details" , new { id = item.ID }) %></span> <sub> Area: <%: item.Area.Nombre%></sub></p> <% } %> <p> <%: Html.ActionLink("Crear Nueva Carrera", "Create") %...