asp.net-mvc-2

ASP.NET MVC - Caching IQueryable Data

I found this question http://stackoverflow.com/questions/343899/how-to-cache-data-in-a-mvc-application and I'm wondering about being able to use this method with IQueryable data. Public Function GetUsers() As IQueryable(Of User) Implements IUserRepository.GetUsers Dim users = (From u In dc.Users Select ...

How can I strongly-type in what my View inherits from?

CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'UTEPSA' (are you missing an assembly reference?) Here is the view code that's trying to inherit: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<UTEPSA.Helpers.PaginatedList<Area>>" %> <asp:Conten...

Moving from visual studio 2008 to visual studio 2010

Hey There ! Any solution to this: Assembly 'DomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ...

how to edit objects with other ie IList<object> or simple object attached to it?

Hi Im stuck on how to do this the best way. In my case I got a Product and it got a Manufacturer Object. So what I do is I pass the product to the view to edit. But when I do the save I look at the product object and Manufacturer is now null. I tried to do a hiddenfor for the Manufacturer Object like I do with id for the product, but t...

How can I serialize entities from an ASP.NET MVC site to XML ?

I am working on an ASP.NET MVC (in c#) site which connects to a database and takes advantage of the entities framework. I'd like people to be able to modify the information in the database from the site (since it seems to me to be much easier to display and validate data via an ASP.NET MVC site than a Desktop app while being much easier ...

Exceptions thrown from Spark views don't get redirected to shared error view

My Setup: Asp.Net MVC 2, SparkViewEngine w/ WebFormsViewEngine Problem: I have the following spark view: <content name="title"> Home Page </content> <h2>Home Page</h2> <p> lalalalalalalalalalala. </p> #throw new NotImplementedException(); When this page loads I get a YSOD instead of my default shared Error view. Views th...

What are the conventions for mapping collections with the default model binder?

In MVC 2, what is the default mapping behaviour for the binder. I saw it once in a blog, but cannot find it again. Particularly in regards to list items. From memory it is something like this: {ModelName}[{id}].{Proptery} Any help would be greatly appreciated, especially an online article that refers to this. ...

Help adding properties to LinqToSql classes

I need to define these two Properties to one of my linqclasses (Employee).. because I need to keep track of the health progress of Employees... Each employee takes monthly PhysicalExams so I defined these properties public decimal? Initial_Mass_Index { get { return this...

Remove Duplicate based on column value-linq

Hi i have many to many relationship between employee and group. following linq statement int[] GroupIDs = {6,7}; var result = from g in umGroups join empGroup in umEmployeeGroups on g.GroupID equals empGroup.GroupID where GroupIDs.Contains(g.GroupID) select new { GrpId = g.GroupID,EmployeeID = empGr...

How to change [DisplayName"xxx"] in Controller?

Folks, I am MVC 2 newbie and stuck on this problem: AccountModuls.cs public class LogOnModel { [Required] [DisplayName("User name")] public string UserName { get; set; } … } LogOn.aspx <%: Html.LabelFor(m => m.UserName) %> The text “User name” will be finally displayed in the website - based on my definition [DisplayName("User ...

How to receive selected Dropdownlist value in [HttpPost] method?

And again a newbie question. ;-) I am setting my View Model based on this very helpfull post: public class My_IndexModel { ... public IEnumerable<SelectListItem> My_DropDownList { get; set; } ... } Please note that I use IEnumerable<SelectListItem> to be able to set the Selected Property. The dropdown list values are...

Configure the spark view engine!

I'm looking at launching a new site using the Spark View Engine, I am however having difficulty finding some referance to the set-up of Spark Using VS2010 and MVC2. Can anyone provide a referance to a guide that describes this process? I've looked at some of the code in the sample but the projects dont convert to VS2010. Before I tear ...

ASP.NET MVC 2 EditorFor rendering the wrong mark up

Hi, I have the following asp.net mvc2 template: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ncontinuity2.core.dto.TrainingLookUpContainer>" %> <%= Html.EditorFor(x => ViewData.Model.TrainingTree, "TrainingCategory")%> You can see that I want to bind it to a model of type TrainingLookUpContainer. The problem is...

Exception handling - Is there a better way?

Hello guys/girls, public bool AddEntity(int parentId, string description) { try { _connection.Open(); SqlCommand command = new SqlCommand("INSERT Structure (Path,Description) " + "VALUES(" + GetPath(parentId) + ".GetDescendant(" + GetLastChil...

Testing Controllers and EF4 without POCO?

Is thera any good way to write Unit Tests for controllers and EF4 without POCOs? I have few repositories, controllers with injected repos and i'd like to write some unit tests (i know, tests should be written before, but noone's done it). To test controller i have to mock HttpContext etc. and inject repo with Mocked ObjectContext gener...

Pass model from strongly typed view back to a controller action - mvc2 VB.net

Hello hello. Here's what I have. I have an MVC application where all the data is tied together by VisitDate table in my database. The home page is a strongly typed view of type VisitDate, all it does is pull up some simple data. Now, here's where I'm having a problemo. I need a link that passes the current model in the view back to a sep...

ASP.NET MVC 2 Url Format Issue

I have a Visitors controller. Inside I have Index and SignIn actions. Here are the actions: public ActionResult Index(int month, int day, int year){ var visitors = visitorRepoistory.FindVisitorsByDate(month, day, year).ToList(); return View("Index", visito...

Some Asp.NET MVC2 Best Practices for managing fat controllers to a Business Service layer

Hello, My controllers are getting large and out of hand. A typical controller does the following: It determines whether a given user has access to a given resource. It validates the ViewModel. It translates the ViewModel into the DTOModel for persistence. It calls repositories to update/create new objects and associated other new obje...

ASP.NET MVC 2 - Simple Search Page

I just started ASP.NET MVC (coming from WebForms) and I'm struggling with some really basic concepts. I want to create a single page that uses a textbox for date input. I would like the date input to be passed to the index of my controller which looks like this: public ActionResult Index(int month, int ...

How do I use EditorTemplates from an AREA outside the current in ASP.NET MVC

Consider a project with 2 Areas. /Areas/Blog /Areas/Dashboard Now say that my Blog area has an editor for the type SpecialBlog. /Areas/Blog/Views/Blog/EditorTemplates/SpecialBlog.ascx What if a view that is part of my Dashboard Area would like to display a special blog? The following code works from Views inside the "Blog" Area but n...