asp.net-mvc-2

Why should I not use an ASP.NET datagrid control in MVC

I don't want to make this into a "which is better... MVC or WebForms" type of question. Im sure that has been asked a bunch of times here already. My Question: If I am building a MVC web project, why should I not use an ASP.NET datagrid control on one of my "Views" .aspx pages? ...

ASP.NET MVC: Accessing ModelMetadata for items in a collection

I'm trying to write an auto-scaffolder for Index views. I'd like to be able to pass in a collection of models or view-models (e.g., IEnumerable<MyViewModel>) and get back an HTML table that uses the DisplayName attribute for the headings (th elements) and Html.Display(propertyName) for the cells (td elements). Each row should correspond ...

Posting a form with anchor link at the end?

I have a form for comments like the one below but after the form is posted I wish to navigate to http://www.myurl.com/mypage#commentform but I don't know how to do this. Instead of changing my form maybe there is a way to return a View with my model and add #commentform to my url? <div id="commentform"> <h2>Leave a comment</h2> ...

TypeConverter prevents ApplyPropertyChanges in EntityFramework

I ran into an interesting problem (hopefully, interesting not just for me :) I am running Entity Framework 1 (.NET 3.5) and ASP.NET MVC 2. I have a Customer class that has many-to-one relationship with Country class (in other words, Country is a lookup table for customers - I described more in this post: http://stackoverflow.com/questio...

Change default browser in Visual Studio 2010 RC

In Visual Studio 2010 (RC) there is no longer a "browse with" context menu when right clicking .aspx pages. How can you change the default browser now? By default it seems to use the operating system default browser, but I would prefer to use IE when debugging ASP.net apps. (I am testing this with ASP.net MVC 2) ...

Handling 2 buttons submit Actions in a single View/Form - ASP.NET MVC 2 RTM

I have a View in which the user is able to upload a file to the server. In this view I also have 2 buttons: one to Upload a file and other to Download the last file imported. In my Controller I created 2 action methods: Import and Export. How could I manage to redirect each button click to the proper action method in my Controller? I...

.NET MVC: How to use .NET controls with MVC?

I am very new to MVC. I've been learning to use plain HTML or HtmlHelpers, eg. for textbox, and get the value back in the Controller using Request.Form. But how do I use .NET controls with MVC? (eg. FileUpload) (The reason I ask is I am trying to use a custom control for uploading multiple files - it's Flajaxian File Uploader, if anyon...

Asp.Net MVC does automatic model validation for DateTime but no others

I'm using MVC 2 with some Models from a LinqToSql project that I built. I see that when I post back to a Controller Action after editing a form that has a DateTime field from the Model, the MVC Html.ValidationMessageFor() helper will nicely display an error beside the Date text box. This seems to happen automatically when the you test M...

Asp.net - MVC1 vs MVC2

hi, can any one precisely explain the difference between ASP.NET MVC1 vs MVC2.. and if i'm having a project in MVC1, how can i migrate it to MVC2 ? ...

RenderAction not finding action method in current controller in current area

I'm creating an ASP.NET MVC 2 (RTM) project that uses areas. The Index action of the Home controller of one area needs to use RenderAction to generate a sub-section of the page. The action called is also defined in the same Home controller. So the call should just be: <% Html.RenderAction("List") %> However, I get an exception: A pub...

Asp.Net MVC2 RenderAction changes page mime type?

It appears that calling Html.RenderAction in Asp.Net MVC2 apps can alter the mime type of the page if the child action's type is different than the parent action's. The code below (testing in MVC2 RTM), which seems sensible to me, will return a result of type application/json when calling Home/Index. Instead of dispylaying the page, the...

How do I repopulate the view model in ASP.NET MVC 2 after a validation error?

I'm using ASP.NET MVC 2 and here's the issue. My View Model looks something like this. It includes some fields which are edited by the user and others which are used for display purposes. Here's a simple version public class MyModel { public decimal Price { get; set; } // for view purpose only [Required(ErrorMessage="Name Req...

Manage actions' and controllers' names in ASP.NET MVC

Hi there. I'm new in ASP.NET MVC, I have many actions in my controllers, so they return different ActionResults like this: return View("blablabla"); or return RedirectToAction("actionName", "controllerName"); etc. So what I don't like about this is amount of hardcoded string values of actions' and controllers' names. If I change the n...

Why 'timeout expired' exception thrown with StructureMap?

I'm getting a the following exception: "Timeout Expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled conections were in use and max pool size was reached." ...from a relatively heavily trafficked ASP.NET MVC 2 site I developed using StructureMap and Fluent NHiber...

How to validate two properties with ASP.NET MVC 2

Hey folks :-) I'm just getting started with ASP.NET MVC 2, and playing around with Validation. Let's say I have 2 properties: Password1 Password2 And I want to require that they are both filled in, and require that both are the same before the model is valid. I have a simple class called "NewUser". How would I implement that? I'v...

What's a good place to learn differences between MVC 1.0 and MVC 2.0?

I have a small project I started in MVC 1 and have resisted (until now) moving to MVC 2. Problem is, everything seems to be just a mishmash of MVC. So... What significant differences are there? What do I need to know to take advantage of what's there? Are there breaking changes? Where's a good place to learn all of this stuff? ...

JQuery timer plugin on ASP.NET MVC Page button click

Hi I have an ASP.NET MVC Page with a button called "Start Live Meeting". When the User clicks on this button, it calls a controller method called "StartLiveMeeting" that returns a string. If the controller returns empty string, then i want the Timer to call the Controller method until it returns the string. I am using jquery.timer.js...

Model binding form to a List using dropdown. binding failing 1 way for dropdown

I have an action called Sessies. In this action i am creating 'Sessies' objects from a form. if they don't exist i add them in the DB, if there are already Sessies objects connected to the 'Reeksen' object, i load the 'Sessies' into the form so that they can be edited. so i have a create and edit in 1 and the same form. Also, a 'Reeksen...

Using Linq to update a List<T> of objects to DB

I have a form that returns me a List of FlatSessie objects in my edit view I edit a few FlatSessie's and get them returned to my Post method in that List object. In my DB I have Sessies, which I map using Automapper to FlatSessie's and back now I can not get linq to make the update to the DB for me. the code: [HttpPost] pub...

Can I disable DataAnnotations validation on DefaultModelBinder?

I want DefaultModelBinder not to perform any validation based on DataAnnotations metadata. I'm already using DataAnnotations with DynamicData for the admin area of my site, and I need a different set of validation rules for the MVC based front-end. I'm decorating my classes with the MetadataType attribute. If I could have different Met...