asp.net-mvc-2

How to use ReportViewer 2010 in MVC.NET 2

Basically I want to know how to embed a report into MVC.Net 2. ...

MVC2 RTM - model binding complex objects using Entity Framework

I am new to MVC, and am really struggling with what I seems like it should be a very common scenario. I'm using MVC2 RTM, and the Entity Framework for my model objects. What I have working: An edit view for a parent object that contains a collection of child objects. The form displays all the editable fields for the parent, and iterat...

How to return errors to view from controller not tied to a specific model property

Curious what the best practice is for returning errors to a view from a controller where the error isn't really a validation error, but more like "user not found" or "service timeout" type of errors. (in ASP.NET MVC2 framework) I've been adding them to the ModelState's model errors, but that doesn't seem appropriate. (although easy to i...

create wizard form in MVC and how to manage view and controller folders

Hi everyone, i need to make a form wizard of 3 steps. Each steps can be saved in the database separatly. The steps will be to enter information about an Company, then his Publications and finally his Reservations. Should i put all the logics in one controller or different controllers? My first thought would be in one controller since t...

How can I inject a ModelState with ninject?

Say I have CompaniesController which uses a CompaniesService. And the Companies Service is where I do all my Business Validation so it requires I pass it the ModelState (Im using a ModelState Wrapper following this... But since I added Ninject to my project I cant figure out how to inject the ModelStateWrapper into the CompaniesService.....

Mixing WebForms and MVC: What should I do with the MasterPage?

I want to start migrating a WebForms App to MVC. The process will be gradual, so both systems must co-exist. The question is: Should I have two MasterPages, one for the WebForms pages and other for the MVC views? Is there a way to have only one? ...

Using List as query string parameter using MVC

Hi. I have an action method that looks like this: public ActionResult DoSomething(string par, IEnumerable<string> mystrings) I wanted to map this to a URL using Url.Action, passing mystrings in the RouteValueDictionary. However, this only yields a query string that only corresponds to mystrings.ToString(). How could I pass a list in ...

Possible to [Authorize] at the Area level in ASP.NET MVC 2?

Slapping on [Authorize] attributes on Controllers and Actions to restrict access is awesome. Is it possible to do the equivalent for an entire Area in MVC 2? Where I can restrict Area-wide access dependent on Roles/Users/whatever in a central place instead of littering them throughout all the Controllers? ...

How to use MicrosoftMvcValidation with jQuery.Ajax in ASP.net MVC2 ?

Hi, using asp.net mvc2, Data Annotations, MicrosoftAjax.js,MicrosoftMvcValidation.js, jquery for ajax I have contact form and i am using Data Annotations for the ContactFormModel. I add this line <% Html.EnableClientValidation(); %> to top of the form. When i click the submit button client validation works perfectly. Now i hav...

MVC Repository Pattern/Web Services SoC Question

Hello, I am new to ASP.NET MVC and I am trying to implement best practices for a small-to-mid size application that uses a web service as its data source. The web service exposes the following methods to support the application: AuthenticateCustomer - returns the customer ID if valid email/password GetCustomer - returns a serialized ...

Routing goes nuts on asp .net mvc 2 application that is the same app set up 2x on the same server.

This is going to sound quite bizarre. I have one ASP .NET MVC 2 application. Works great. Routing is not very complicated. I am running this on windows 2003 IIS 6, so I have to use the {controller}.aspx routing configuration. Anyhow, I've set the same MVC 2 application up twice under different virtual directories on IIS. This is litera...

I can`t decide what to select: ASP.NET MVC 2 (C#) or Django (Python)?

I`m learning programming languages. And I decide that I need to lear a new web framework. I have 2 candidates: Django or ASP.NET MVC 2. Can you say me the difference between them and what is so interesting? ...

dropdownlist issue

I have a dropdownlist generated from db. Here is the result from page source. <select id="testList" name="testList"> <option value="0"></option> <option value="0">A</option> <option value="1">B</option> </select> Does anyone know why the empty is still zero? How come I dont get something like "" for the first one since it's empty? <d...

ASP.NET MVC pass data in link not through url

I don't know if this defeats the purpose of MVC, but I'd like to have a controller that accepts 2 variables but I don't what to pass them the url. Is there easy way to do that? public ActionResult Return(string user_id, int item_id) Right now I'm making links like this <%: Html.ActionLink("Return", "Return", new {user_id = item.user_...

How to get swfupload to work with Asp.Net MVC 2

I'm trying to use the swfUpload jquery/flash plugin for uploads, and I'm following the approach by Steven Sanderson (http://blog.stevensanderson.com/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/ ). But I can't get it to work. It works fine in the sample application I downloaded from his site. Just to try to get it to work I h...

format int to phone number

Is there a way I can format for example: 0000000000 into (000)000-0000? I'm returning a listbox which holds a collection of phone number which arent formated yet. What I would like is format it. This is what I have in the View: <%= Html.ListBox("phoneList")%> and from the controller: ViewData["phoneList"] = new SelectList(phoneList)...

FileResult returning corrupt file

I'm creating a simple controller action in ASP.NET MVC 2 (under the .NET 4.0 framework) which will resize files. I've got a controller like this (I've cut it down a bit): public ActionResult GetFile(int fileId, string fileSource) { FileInfo file = repo.FindFileById(fileId); //do some resizing string mimeType = string.Empt...

How to get data of EditorFor with nested viewmodels

Hello guys/girls, Here is my situation - I have two nested view models: <%=Html.EditorFor(x => x.DisplayEntitiesWithRadioboxesViewModel)%><br /> Which sit within their parent (StructureViewModel), I can populate the nested ViewModels easily and pass it through to the main View: Within the Controller - Example var moveDepartment ...

c# Extension method

Hello, Im trying to test my extension method that converts a list of strings in a string comma separated: public static class Extensions { public static string ToCommaString<T>(this IList<T> input) { StringBuilder sb = new StringBuilder(); foreach (T value in input) { sb.Append(value); ...

MVC2 issues when edit an item on an textboxfor

Hello, i have this model on mvc: public class User { public string Name { get; set; } public IList<string>RelatedTags { get; set; } } And the following typed view (user) to edit an add a user (AddEdit.aspx view): <div> <%: Html.LabelFor(e => e.Name)%> <%: Html.TextBoxFor(e => e....