asp.net-mvc-2

Understanding the label helper method, specifically the "for" property of the rendered HTML

I have a strongly typed partial view CheckBox.ascx that renders a checkbox. This is used by another partial view that renders a list of checkboxes using CheckBox.ascx. I am having problems figuring out how to use the Html.Label helper method to get labels working correctly, i.e. setting the label for property to be the id of the related...

ValidateModel Problem with DataAnnotations

I have a SearchViewModel with these properties: [RegularExpression("name")] public String SortField; [RegularExpression("asc|desc")] public String SortDirection; As you can see, I want "name" to be the only valid value of SortField at this time, and "asc" or "desc" the only valid values for SortDirection. However, Va...

Html.RenderPartial user control retaining input focus in FireFox 3.6

Using jQuery Lightweight RichTextEditor plugin. When I use a partial view (user control) on my page the textarea rendered retains input focus even though I'm explicitly setting focus on the page load (setting z-index doesn't work either): $(document).ready(function () { $("input:text:visible:first").focus(); }); In Vi...

using mvc futures renderaction modelstate.isvalid is never false

I'm using MVC 2 and MVC Futures 2.0.50217.0. I started with a view which repeatedly calls RenderAction(...) to include some external content implemented by another controller within my application. This is from the containing view: <% foreach (var subModel in Model.SubModels) { %> <h3><%: subModel.Title %></h3> <% Html.RenderAc...

Transactions in MVC asp.net

Hi, Was wondering if there are any transactions support in asp.net for MVC 2? i.e. commit & rollback? I have a few slightly risky db transacts which i'd prefer firmed up with transactions. could the system transactions namespace be incorporated into a respository of db calls? ...

Consuming a ASP.NET MVC 2 JsonResult like a web service in a web forms C# application?

A friend wants to consume my ASP.NET MVC 2 application in a similar fashion as adding a web reference to it, accessing my functions, and using my model objects from a .Net web form from a separate website. Any links out there that could explain how to "dress" my MVC responses so that his server to server consumption would be similar in ...

Data Annotations and MVC 1:1 ViewModel

When developing in ASP.NET MVC I use a 1:1 ViewModel setup where the viewmodel contains only the data required by the view. I'm also using data annotations to validate on the viewmodel. My concern is that this is not following the DRY principle as I find myself having to duplicate validation throughout my sites. I'd love to have validat...

asp.net mvc 2 view extensions, new project

I've created a few html helper methods for asp.net mvc that I would like to use between projects. Does anyone know of a way to put them in their own project file so I can include that in other solutions? I've tried this but it doesn't seem to work. When I try to use the helper it complains that htmlHelper is not being set. It isn't nece...

ASP.NET MVC Custom Routing Long Custom Route not Clicking in my Head

I have spent several hours today reading up on doing Custom Routing in ASP.NET MVC. I can understand how to do any type of custom route if it expands from or is similar/smaller than the Default Route. However, I am trying figure out how to do a route similar to: /Language/{LanguageID}/Question/{QuestionID}/ And what I would like, too,...

How to get password html helper to render password on failed validation

I have a form for creating a new account and it has a password field in it. I'm using view models to pass data to the controller action and back to the form view. When the user enters their details in, and clicks submit, if validation fails and it returns them to the same view passing back in the view model, it won't default the password...

What is the difference between ASP.Net MVC and ASP.Net MVC2?

I've decided to take the suggestion from Robert Harvey on this site and build an application using ASP.Net MVC. When I went to Bing for a brief overview, I saw there was an MVC2. What is the difference and should I care? ...

Setting Response.StatusCode in View in ASP.NET MVC2

I've just converted a project from MVC1 to MVC2. In the MVC1 project the HTTP status code was being set in some of the views. These views are now generating this exception: Server cannot set status after HTTP headers have been sent. What has changed from MVC1 to MVC2 to cause this and is there any way to fix this? ...

What are the "Navigation Properties" in this data model for?

I've been wondering how to properly set up many-to-many relationships in ASP.NET MVC 2 using Linq2Sql for quite some time now. I found this blog post that seems to have a similar model layout as mine. If you take a look at the first screenshot showing the data model you can see that each model has "Navigation Properties" at the bottom ...

Inline HTML Syntax for Helpers in ASP.NET MVC

I have a class that extends the HtmlHelper in MVC and allows me to use the builder pattern to construct special output e.g. <%= Html.FieldBuilder<MyModel>(builder => { builder.Field(model => model.PropertyOne); builder.Field(model => model.PropertyTwo); builder.Field(model => model.PropertyThree); }) %> ...

ASP.Net MVC 2 / EF 4 Reference Issue

My ASP.Net MVC 2 project references a Domain project where POCO business objects are defined and a Data project where EF 4 POCO persistence is implemented. Things were running well until I had a little fussiness with my version control provider (rollback to previous version left me with merge conflicts). Now, upon launching the MVC 2 p...

Trying to return data asynchronously using jQuery AND jSon in MVC 2.0

Hi, I am trying to use Jquerys getJSON method to return data server side to my browser, what happens is the url the getJSON method points to does get reached but upon the postback the result does not get returned to the browser for some odd reason. I wasen't sure if it was because I was using MVC 2.0 and jQuery 1.4.1 and it differs to t...

accessing viewmodel data in MVC2.0 view

I am working on my first ASP.NET MVC 2.0 app and realized that I am still confused about the best way to manage views. For debugging, I would like to quickly dump data from several model classes into one view. I created a viewmodel class that combines the data into a single object. public class DBViewModel { public IQuerya...

asp mvc 2.0 Partial View(ajax) and xval valdiation

Hi, I want to do some server side validation that is done on Action not in model (dataannatations). if(ok) //somecode else { ModelState.AddModelError("", "Some error"); } For that example I don't get any notification with validation summary. Even if I put property nam...

How to add properties to users in ASP.NET MVC2?

After I have the initial ASP.NET MVC 2 website and the default Membership provider up, how do I start adding features specific to an user? Like, say, we want to let users choose their favorite products and we want to remember these choices somehow or add a favorite color property to an user? Where should these customizations go and how...

MVC2 Areas and Controller 404

My project namespace is MyProject.MVC So my controllers, which are segregated into Areas, are in this namespace: MyProject.MVC.Areas.AreaName But when I try to access a controller action in this namespace, I get a 404 error: http://MySite/AreaName/Action/View If I "remove" the MVC portion from the namespace on my controllers, ev...