asp.net-mvc

ViewData resets inside ASP.Net MVC controls

I have 2 instances of a user control (ascx) in a view page. I set ViewData["xyz"] = "True" inside the user control. The first instance would set ViewData["xyz"] to "True". However, this same value is not retained in the second instance of the user control. I was expecting ViewData["xyz"] to be still "True", but it is null. Please hel...

Should I keep working on my project on MVC 1.0 or stop and learn MVC 2.0?

Hello, Few months I've started learning ASP.NET MVC 1.0. Although hard in the beginning, now I've made huge progress so that I'm working on something serious I can show to my colleagues. But, now MVC 2 is almost out there. Now I would like to know if MVC 1.0 and MVC 2 are profoundly different. In fact, I wonder if I need (first) to fi...

ViewModel with SelectList binding in ASP.NET MVC2

I am trying to implement an Edit ViewModel for my Linq2SQL entity called Product. It has a foreign key linked to a list of brands. Currently I am populating the brand list via ViewData and using DropDownListFor, thus: <div class="editor-field"> <%= Html.DropDownListFor(model => model.BrandId, (SelectList)ViewData["Brands"])%> ...

ninject 2 and db4o

Hi, I am trying to use ninject with db4o and I have a problem. This is the relevant code from the Global.aspx static IObjectServer _server; protected override void OnApplicationStarted() { AutoMapperConfiguration.Configure(); RegisterRoutes(RouteTable.Routes); RegisterAllControllersIn(Assembly.Get...

Building a forms system using DDD

Hi, i'm building a form managment system, thats is, the system will contain many forms, will save them, and perform logic on them, I want to do it using the DDD approach. I want to support easy form layout later on using ASP.NET MVC, so far i see the domain like this: I'll have a base form entity, which should(for now) have a name, fie...

asp.net MVC jquery grid

I am trying a hello world project with ASP.net MVC and jquery grid Followed the steps as per http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx Everything seems to be fine when hitting F5 from VS2008. the grid is showing the data from the db Now, when I set up a virtual directory and pointed to the same proj...

Dynamic Range Validation in ASP.NET MVC 2

I am using ASP.NET MVC2 and trying to validate my view models using the attributes in System.ComponentModel.DataAnnotations namespace. How can I dynamically set the permitted valid range of a RangeAttribute? For example, if I want to validate that a date entered is within an expected range. This doesn't compile: [Range(typeof(DateTime...

Asp.NET MVC strong typed controllers

I saw somewhere code like this: return View(x=>x.List()); Instead of return View("List"); What do I need to achieve this ? I'm using Asp.net MVC 2 RC 2 EDIT I do not mean strong typed views Next example return this.RedirectToAction(c => c.Speaker()); ...

mvc and partials is this not breaking the mvc pattern?

Hi Guys I have a partial view that displays a search options like search by category, region, date etc. This exists on every page. The partial uses a viewmodel containing lists of regions, cats etc. As this is being used on every page - I have to load these properties on the viewmodel in every action in my controllers to ensure the dat...

Best practice for using JavaScript on partials and views in ASP.MVC?

I started removing part of a view into a partial so that it could be reused on another view. However, I got stuck because there are some JavaScript functions on the original view that call some of the functions that belong to the partial. It seems wrong to call functions that are defined on the partial from the containing view (and vice-...

Populating Selectlist from multiple fields

My problem is pretty simple. Lets say I have a dropdown with users. in the database i have 3 fields for my user table: user_id user_name user_firstname in my MVC app i want to link those users to projects. so thats why i want the dropdown. now, i want to have a selectlist, with the ID as the value, and the firstname AND lastname t...

Annoying errors with ASP.NET MVC - The Type or namespace name could not be found

I'm new to ASP.NET MVC and I'm creating an app that will search a contact using using the autocomplete functionality along with jquery. When I run the project it loads fine and when i click the submit button to search a lastname i receive an error. Server Error in '/' Application. The resource cannot be found Requested URL...

Saving a picture from a browser canvas.

Hello I'm currently developing a website in ASP .NET MVC and I require functionality for a user to be able to draw a picture on a canvas which can be saved in a database. What is the best method for doing this? preferably a very lightweight solution. I was thinking flash would be the most accessible platform and there may be some good f...

SubSonic 3 Class Table name generate issue

Hi everyone! i´m a novice in the Subsonic, and i have a isseu about the way how it work´s. When subsonic generate de .cs file for default the name of the classes comes in LowerCase. I have edited the MySql template using the funciton "ToTitleCase()" it´s resolved a peace of my problem, if my table name is Products i´ts ok, but if is t...

Why am I getting duplicate exception entries using ELMAH in ASP.NET MVC?

I'm brand new to ELMAH but I've been working with MVC for a little while now. After reading several blogs on the subject I'm pursuing the road of having an ErrorController that handles 404 and unknown-error pages, and making a default route that forwards all unknown paths to the 404 action on that controller. The problem is that ELMAH ...

MVC 2 RC RedirectToAction woes

Hiya! I have setup a custom route as defined in my global.asax: routes.MapRoute( "Search", "{controller}/{action}/{type}/{searchterm}", new { controller = "Search", action = "Results", type = "", searchterm = "" } ); Now all I want to do it in a controller when data is passed via POST basically go in the form...

Load Web.Config as embedded resource inside a DLL in ASP.NET MVC

Following on from my earlier question around loading views from DLLs under ASP.NET MVC, I've come across the issue of having Views and Controls be strongly typed. An exception is thrown indicating that the type cannot be resolved. I found this article which describes implementing a web.config section which allows that strongly typed vi...

Asp.Net MVC How to unit test an ActionResult that returns Content?

For instance if I wanted to unit test the following controller what do I replace ???? with? using System.Web.Mvc; namespace MvcApplication1.Controllers { public class StatusController : Controller { public ActionResult Index() { return Content("Hello World!"); } } } [TestMethod] public v...

Onion archicecture dependencies in the same layer: Infrastructure and Web communicating

I am designing an ASP.NET MVC application using the Onion Architecture described by Jeffrey Palermo. It is an ASP.NET MVC 2.0 project, where I am requiring that all views be strongly typed using dedicated View Models -- we will not be passing domain models to our views. We are using AutoMapper to do the translation -- AutoMapper is isol...

CSS Files in ASP.NET MVC with a master page

I'm designing an MVC site, and I've already got quite a few things in the Site.css that only apply to one controller or even one page. I'd like to break this out into multiple css files and include them only when necessary, but how can I do this when all header information is in the Site.Master. Note: I still want to use master pages, ...