asp.net-mvc-2

ASP.NET Mvc - nullable parameters and comma as separator

Hello. How should I define route in my global.asax to be able use nullable parameters and coma as separator? I'm trying to implement routing rule for my search users page like "{Controller}/{Action},{name},{page},{status}" Full entry from the Global.asax: routes.MapRoute( "Search", "{controller}/{action},{name},...

Understanding Forms in MVC: How can I populate the model from a List<>

Conclusion in Images, can be found in the bottom I'm having some trouble to get how Forms work in MVC (as I'm a WebForms Developer and really wanna start using MVC in one big project) I took the MVC2 Web Project and add a simple ViewModel to it namespace TestForms.Models { public class myFormViewModel { public myForm...

How do I pass a selected ID from a Html.DropDownList in an Html.ActionLink

I have a DropDownList: <%: Html.DropDownListFor( c => c.DataTextField, Model, "Please Select Contract", new { id="selected-contract"}) %> And I want to access the selected item id in a Html.ActionLink: <%: Html.ActionLink( "Add Contract Item", "CreateContractItem", "Contr...

EnableClientValidation with multiple forms

Hello, I am trying to use the Client-side Validation with jQuery in ASP.NET MVC (2). I've found this great example which works fine but I am having problems when I try to use a custom name for my form. It seems that the EnableClientValidation methods uses the default form name "form0" to inject the client script and doesn't support any...

How to use this.Html.DisplayFor to render a strongly-typed partial for poco object

In views/home/index.aspx: <% this.Html.DisplayFor(m => m.NewLink); %> index.aspx is strongly typed to HomeViewModel.cs, which has the property used above right here: public Link NewLink { get; private set; } (in constructor), this.NewLink = new Link(); In views/home/displaytemplates/addform.ascx: <%@ Control Language="C#" Inherits...

How to override DataAnnotations Required tag to allow conditional client side validation

I am using DataAnnotations tags for client-side validation in ASP.NET MVC2. I am using the Required tag, but in my case marking a field as required is not always an absolute. I have other conditions that determine whether or not a field is required. Is it possible to override the required tag to allow for this conditional logic? I wo...

Simple Selenium Test Gives XHR ERROR : 404

Hello, I'm using selenium-rc with C# to test my asp.net mvc2 application. Currently all I am doing is opening the home page with selenium RC. when I run my test I see the selenium remote control open in a browser and I see my application open correctly in a browser but selenium shows a 404 error and aborts the test. In an attempt to g...

How do I get DotNetOpenAuth to open a popup window for authentication?

Hi, I am relatively new to web development, so perhaps this is a rookie question. I am trying to set up an ASP.NET MVC web site to implement DotNetOpenAuth as an OpenID relying party. Right now it is all functioning, so that is pretty exciting. My goal though was to have the OpenID authentication take place it a popup window. This...

How do I need to show the Selected Account in the Dropdownlist box using Asp.net mvc

Hello Friends, I have this code in my View.. <tr><td>Account:</td><td><%=Html.DropDownList("drdAccounts",Model.AccountsListHeader),Model.selectedAccount,"Select Account", new { onchange = "JavaScript:AccountChanged()" })%><span class="requiredAsterisk">*</span></td></tr> But I am getting Error Description: An error occurred during t...

Facebook page style urls in Asp.Net MVC

How would I write a route in Asp.Net mvc to handle a url like this one for a Facebook page: http://graph.facebook.com/http://codedojoboise.com/ I tried this route but get a 400 Bad Request error when I try to run it. routes.MapRoute( "LinkPreview", "LinkPreview/{path}", new {controller = "LinkPre...

Cannot find any coverage data (ASP.NET MVC2)

I am having some issues with getting Code Coverage working with an out-of-the-box ASP.NET MVC2 Web App VS2010 Ultimate, File > New Project > ASP.NET MVC 2 Web Application > Yes, Create unit test project with Visual Studio Unit Test. I then Rebuild All, Run All Unit Tests, Go to Code Coverage and get the following message: "Cannot find ...

Unit Testing ASP.NET MVC Controllers with Ninject

I recently upgraded Ninject to the most recent builds to fix this issue: ninject binding issue As far as I can tell, it corrected the issue, but it seems to have messed up my controller unit tests. I now get the error that I was trying to fix when running my unit tests. The error is: Error activating ISomething More than one ma...

Support tables - create a controller for each?

Hello, my app has a lot of support tables that requires admin UI interface to maintain - for ex: Countries, States, Cities etc. I am not sure if it would make sense to add CRUD actions for each of them in one AdminController or create a Controller for each individual support table. ...

ASP.NET MVC 2 Custom view engine

hi, Im developing a custom view engine for implementing themes for my asp.net mvc 2 web app. The problem that I am facing is that in this function: public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) The parameter "masterName" is always empty, although the ...

ASP.NET MVC navigation route that changes based on viewed data

I am in the process of creating tabbed navigation where the route location can vary. The parameter used to render the tabs should be based on the presently viewed data (which when it is a user, may not be the logged in user). In the example image this is a user. Therefore, if I am looking at Andrew Steele then the links should be contex...

How to pass Title for a view that uses a Linq Collection

I'm learning Linq and MVC2 I'm making progress, but I'm a little stuck on how I should get a page descrption into a View that uses a collection. In my controller I have the following construct public ActionResult Group(int id) { var result = (from d in db.ErrorDetails.Where(r => r.ErrorTerminal.ErrorTerminalGroupID == id) ...

Deploying MVC2 application what DLL's should be already present

I've just deployed my first MVC2 application to our Local Webserver (it's in our network so it can be fixed/changed as needed). The server was originally built with .Net 2, and our network admin installed the .Net 4, so I'm not 100% sure if everything is in the correct places. What I'm wondering is should all the System.Web.* etc DLL's ...

MVC2 Partial View - Code behind

I'm creating an MVC2 site which is a new, refreshed version of a site built in Web Forms. Due to the nature of some of the features and the a database of statistics and their structure there is no one-size-fits-all way to display some of the information needed to be displayed. Thus, despite following MVC principles elsewhere, in one fe...

mvc2 multiple content place holders

Hi, multiple content place holders..1 with a text entry box and a submit button.. the second content place holder has several options in.. when i perform the submit the options from the 2nd place holder aren't getting passed through. can you suggest a method on how i can perform this submission passing all values to my controller? the va...

ASP.NET MVC 2 - Authentication form doesn't fire the action

Hi Hi have a form that call an Action properly. But when i enable the authentication forms, the action to login doesn't fire up (i test it with a breakpoint). My Web.config is: <authentication mode="Forms"> <forms loginUrl="Autenticacao/Index"></forms> </authentication> <authorization> <deny users="?"/> </autho...