asp.net-mvc-2

Can't load a DropDownList with values.

I'm following the NerdDinner tutorial while building my own application. The tutorial gives this: public ActionResult Edit(int id) { Dinner dinner = dinnerRepository.GetDinner(id); ViewData["Countries"] = new SelectList(PhoneValidator.AllCountries, dinner.Country); return View(dinner); } My code is like this: public ActionResult ...

Help me create a dropdownlist of all Jefes in my database!

Hi guys, I have the following table structure: I'm trying to populate a combobox of all the Jefes when editing an Area. Meaning I can change who's in charge of an area. Here is my AreaController.cs code: public ActionResult Edit(int id) { Area area = areaRepository.GetArea(id); JefeRepository jefe = n...

ASP.NET MVC 2: What Model property datatype will autobind an html select (DDL) with multiple selections?

The customer has a Model property that requires a comma separated list of selected options. We present their select list (DDL) as a multi-choice drop down. What would the property datatype look like that would autobind multi-selections in the client side HTML select (DDL)? The select posts data like this: myOptions=Volvo&myOptions=Me...

Help learning ASP.NET MVC

I am not a web programmer by any definition. I am more interested in the language and some low-level stuff. I like a simple, small language like C that has a fairly small grammar set with a vocabulary that is fairly large. I like programming in an environment where I know what's going on. I feel very awkward working with frameworks that ...

Render ASP.NET MVC view from a string

This may be a bad idea for any number of reasons, but I still want to accomplish it. Is there a way to render a view from a string that contains some HTML and code blocks? My initial thought is that I would implement IView and have that take the HTML string in the constructor. Then pass it to the View method along with the model, like so...

How can I avoid having to write boilerplate code?

Well, I've been following the NerdDinner tutorial online and I've completed it to a T. Now I've implemented a project of my own using pretty much the same architecture. I notice my process is: Create database. Create DBML. Create |TableName|Repository.cs class with data access methods. Create partial |TableName| class to handle valid...

Where do I put picture in my ASP.Net MVC2 application?

Where do I place images within my solution? ...

ASP.NET MVC & JQuery UI Drag Drop - Does anyone know how to store/retrive the panel state?

I have used the Telerik RadDock in the past, and although it's pretty good, it is a little bit clunky and bloated. One nice feature is the ability to save the state of a page (all dock locations, etc) in the database and recover them at a later date. I'm wondering if there is a way in MVC and jQuery to save the state of the jQuery UI D...

How does the session state work in MVC 2.0?

I have a controller that stores various info (Ie. FormID, QuestionAnswerList, etc). Currently I am storing them in the Controller.Session and it works fine. I wanted to break out some logic into a separate class (Ie. RulesController), where I could perform certain checks, etc, but when I try and reference the Session there, it is null....

ASP.NET MVC2 - Trim of whitespace on all fields in a model?

Hi, I have data coming in and out of an ASP.NET MVC2 Controller/View set-up. Unfortunety, all data that comes from the view has MASSIVE amounts of whitespace at the end. I'm using the TryUpdateModel to save all form data to the Db after it passes validation, passing a FormCollection as a parameter(eg. form.toValueProvider). Is there ...

ViewModel is empty MVC2

Hello all, When I press the submit button and access the Controller my ViewModel is empty. I don't know why this is happening, I have similar code to this on the other views and they do pass through data. Controller public ActionResult DeleteCategory(int id) { var data = _service.GetIndividualCategory(id); ...

Displaying data objects mapped by ID elegantly in views

I have a bunch of support Cases and Users. Each Case is assigned to a User with a unique ID. My data model represents this with an AssignedUser user ID reference. This is easy to store and retrieve, but not convenient to display. When I want to display a list of Cases, the user property should be formatted as the user's username and not...

Lightweight logging library for ASP.NET MVC 2

Hi everyone! I need a lightweight logging library for ASP.NET MVC2. It only needs to support storage of messages in the database and sending emails for critical errors. What do you recommend besides log4net? Thank you. ...

Custom validation attribute with multiple instances problem

I'm using tha namespace System.ComponentModel.DataAnnotations in C# 4 to implement my own validation attribute and it looks like this [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public sealed class MyCustomValidator : ValidationAttribute { private String Property1 { get; set; } private String Property2 { get; ...

Question regarding fine-grained authorization and MVC2

Background: Completely new to MVC2. Has C# experience, but limited web experience. I need more fine grained access than simply assigning a Role to a user. The user may have the role at 0+ points in a tree. / /Europe /England /France /USA For example, a user might be moderator of all forums under "Europe" and have access t...

Does using ViewModels and references to System.Web.Mvc violate the MVC pattern?

I've seen it all over SO, blogs, and books, where the authors tell you add ViewModels specific to your View in your Model projects as wrappers for your underlying model objects. The idea is to make it very simple and targeted when you go to do model binding to the View. Here is a good example: Rendering and Binding Drop Down Lists using ...

Content-Aware Route Mapping in ASP.NET MVC 2

I am working with ASP.NET MVC 2 and would like to optimize my routing. The desired result is as follows: http://www.url.com/Sites/ http://www.url.com/Sites/Search/NY001 http://www.url.com/Sites/NY001 http://www.url.com/Sites/NY001/Photos The problem with this scenario is that I want to treat the URL bits differently depending on their...

How to store data of complex types for use in Javascript?

This is a reoccurring theme: either AJAX causes data to be requested from the server and then the data is shown to the user or the page is pre-populated (ie. rendered) with data that has some kind of interaction with Javascript. Here are couple of possibilities I see how to store and manipulate the (complex) data: Store the data simpl...

Secure elmah with ASp.NET security but only to some users

HI, I am developing a ASP.NET App and I want to add elmah. The problem I have is the the users login to the site and the only way I found to secure elmah is to authenticate users, not a specific user. I am using ASP.NET MVC 2 and NET 4. Any Ideas? ...

FireFox randomly breaks login?

Update: I finished my app using NerdDinner 1.0 as a starting point. NerdDinner 2.0 had a more robust AccountController so I line for line did a complete replace of my AccountController v1. It was at this point that I started having login issues with FireFox (confirmed with a revision rollback). There are several differences on the whole ...