asp.net-mvc-2

Internal Browser for debug for local Azure ASP.NET MVC2 under Visual Studio 2010 RC ??? !

The title says it all! Wanting to have IE open in a tab in Visual Studio, rather than as a separate IE. ...

Intellisense not working for ViewModel for MVC2 project in ASP.NET MVC2 RTW

I upgraded to MVC2 RTM with VS2010 RC and some of my ViewUserControl and Page controls don't show intellisense for simple things like <%= Html..... %> or <%= Model... %> ...

login restriction with ldap, but where to store the functional rights/access control list?

Question is: LDAP authentication required Internal users automatically authenticated, external users requires login Where do I store complex access control rights? In the AD/LDAP or in the Application itself (asp.membership db). What is your experience and best practices suggestion? Looking to build this in asp.net mvc 2 and using...

Autofac in Asp.net mvc 2

I want/need to compile autofac with asp.net mvc 2 website. I want to step thru the source to see how it works. But here is my problem. The binaries for mvc dll is apparently bound for asp.net mvc 1. I am having trouble working out what the settings for the project file need to be for .Net 3.5 and asp.net mvc 2. one is the NET35 directiv...

How do I pass Url Parameters on a POST?

I have a controller method with the following signature: [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateValues(int id, MyViewModel[] array) { } The id is normally picked up as part of the Url on other GET controller methods (I have a working route that does this) I am successfully passing the array1 from the form in my view ...

ASP.NET MVC - dropdown list post handling problem

I've had troubles for a few days already with handling form that contains dropdown list. I tried all that I've learned so far but nothing helps. This is my code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using CMS; using CMS.Model; using System.ComponentModel.DataAnnotations; namespace Portal....

How to format a date in a view for two-way binding in MVC 2?

So let's say I have a view that access a date: <%= Html.TextBoxFor(model => Model.Birthday) %> How do I have my view dictate how that date is formatted? I'd like to use common formatting options, and it's important that this is 2-way (both for display and data-entry). ...

Broken RenderPartial After Upgrade To ASP.NET MVC2

I upgraded a MVC1 project to MVC2, now all my calls to RenderPartial are throwing System.ArgumentNullException: Value cannot be null. However this does works: <% Html.RenderPartial("~/Views/Shared/LogOnUserControl.ascx"); %> And this does not (works in MVC1): <% Html.RenderPartial("LogOnUserControl"); %> Did the behavior of Rende...

Best strategy for HTML partial rendering based on multiple dropdown values

I have a View that renders something like this: "Item 1" and "Item 2" are <tr> elements from a table. After the user change "Value 1" or "Value 2" I would like to call a Controller and put the result (some HTML snippet) in the div marked as "Result of...". I have some vague notions of JQuery. I know how to bind to the onchange event...

UpdateModel() fails after migration from MVC 1.0 to MVC 2.0

We are in the process of migrating our ASP.NET MVC 1.0 web app to MVC 2.0 but we have run into a small snag. In our report creation wizard, it is possible leave the Title text box empty and have it be populated with a generic title (in the post action). The code that does the update on the model of the Title is: if (TryUp...

Modify post data with a custom MVC extension?

So I'm looking into writing some custom MVC extensions and the first one I'm attempting to tackle is a FormattedTextBox to handle things such as currency, dates, and times. I have the rendering of it working perfectly, formatting it, working with strong types and everything all golden. However, the problem I'm now running into is cleanin...

Should I replace string patterns in asp.net mvc using a custom viewengine?

Have an ASP.NET MVC site that is localized. The localization functionality adds the two digit language ID to the URL, e.g. /es/Page. If no language Id is found in the URL, the site switches to the user's browser culture. All's good. However, the site's hyperlinks, a mixture of hard-coded href tags, actionlinks, etc., don't include the ba...

[ASP.NET MVC] How to eliminate ReturnUrl from the browser address

Hi, guys. Now on unauthorized attempt to access an action my ASP.NET MVC app redirects user to the login page and generates URL shown below: http://www.mysite.com/Account/Log?ReturnUrl=%2Ftest%2Fsampleaction So, is there a way to eliminate this string from the URL, but to save it somewhere to be able to redirect user back after login? ...

alternative to JQuery form.submit() to do ajax post

Hello, I have a mvc2 application with a view like this <% using (Ajax.BeginForm("UserApprove", new { id = Model.id }, new AjaxOptions() { UpdateTargetId = "statusLights", OnSuccess = "HideButtons" }, new { id = "UserApprove" })) {%> <input type="button" value="Approve" onclick="$('#dialogApprove').dialog('open')" /> <div id="...

Unexpected Html.EditorFor behavior in ASP.NET MVC 2

I am getting some unexpected behavior from Html.EditorFor(). I have this controller: [HandleError] public class HomeController : Controller { [AcceptVerbs(HttpVerbs.Get)] public ActionResult Lister() { string[] values = { "Hello", "world", "!!!" }; return View(values); } [AcceptVerbs(HttpVerbs.Post...

Incremental Sequencing DropDownListFor Binding?

I am using incremental sequencing for a collection of objects in a form. All works fine and dandy except when I need to use DropDownListFor. Lots of questions concerning binding a dropdown and selecting the correct value, which is working fine in my case. However I am unclear on what is supposed to have on the HttpPost action in my contr...

How to get ID of EditorFor with nested viewmodels in asp.net mvc 2

So I have two nested view models, CreditCard -> BillAddress. I have a view, "EditBilling", that has EditorFor(CreditCard). The CreditCard EditorTemplate has EditorFor(BillAddress), and the BillAddress EditorTemplate has EditorFor(BillState). The end result is a select list with id "CreditCard_BillAddress_BillState". I need to referenc...

Linq2Sql loading associated model in a new instance.

Hi all I have a collection of new instances of a linq2SQL object. They were created by the default MVC 2.0 model binder. The created instances include a foreign key to an associated model. The created instance does not include an instance of the associated model. I'd like to populate the associated model based on the foreign key. What is...

MVC 2 Entity Framework View Model Insert

This is driving me crazy. Hopefully my question makes sense... I'm using MVC 2 and Entity Framework 1 and am trying to insert a new record with two navigation properties. I have a SQL table, Categories, that has a lookup table CategoryTypes and another self-referencing lookup CategoryParent. EF makes two nav properties on my Category...

Using ViewModels in ASP.NET MVC 2 - multiple forms

I couldn't find any documentation around using multiple forms in an ASP.NET MVC 2 ViewModel approach. i.e. In the built in application when you select New MVC2 web app, the register page uses a ViewPage which inherits like this: Inherits="System.Web.Mvc.ViewPage<rs30UserWeb.Models.RegisterModel>" I wanted to use that approach on a pag...