asp.net-mvc-2

ASP.NET MVC passing data between forms

Hi there, Im pretty new to ASP.NET MVC, trying to figure out my way around. Currently i return a ViewModel which has a IEnumeable Events as its only property. This ViewModel is StronglyTyped to a UserControl which dislays the IEnumable Events in tabular form. One of the properties of the Event Model is an XElement, which contains some...

How to use templated helpers with ViewModels?

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ProductViewModel>" %> <%= Html.DisplayFor(m => m.Product.Name) %> Does not work. It says: "The type arguments for method ... cannot be inferred from the usage. Try specifying the type arguments explicitly." ...

Conditional/limited access in a controller/view? (MVC2)

I have two roles being used on my site currently, author & admin. Authors cannot access user administration functions. However, they should be able to edit certain parts of their profile. An admin is currently able to edit all parts of a user's profile. For example: employee ID [admin] display name [author,admin] roles [admin...

MVC 2 RegularExpression for a single letter is not working

I have a Regular Expression Validation for a Single Capital Letter, but it does not work. When I put in a valid letter, I get the error message; [DisplayName("Contract Letter")] [RegularExpression("[A-Z]", ErrorMessage = "Must be a letter")] [Required(ErrorMessage = "A Letter is required")] public string ...

Best practice for sending Grid data in ASP.NET MVC 2 from View to Controller

I am new to ASP.NET MVC 2 and would like to know what the easiest and/or best practice is to send "grid data" from a View to a Controller. Think of this "grid data" as an excel spreadsheet where some columns will have some data and some rows will have some data. In the controller I need to know not only what column and row contains dat...

Optional routing parameter with constraint in ASP.NET MVC 2?

If I have a route like this: routes.Add(new Route("{controller}/{page}", new RouteValueDictionary { { "page", UrlParameter.Optional } }, new RouteValueDictionary { { "page", @"[Pp]age\d+" } }, new MvcRouteHandler() )); Then the route doesn't match when {page} is missing, however if I remov...

ASP.NET MVC Routing

Hi, I'm having this strange routing problem - I have 2 kinds of routes to the same view. Such as Simulator/RunStrategy/7 and Simulator/RunStrategy/7/1000. Where as the controller and view is defined as public ActionResult RunStrategy(int id, decimal sum). When I use the short one I see the view as needed, when i use the long one - I g...

Ninject Asp.net mvc 2 404 errors?

When I debug my asp.net mvc 2 application and I put a break point on my action that is called when a 404 error occurs every time I invoke any action my error action gets called but the view does not get displayed. This is in my web.config (copied from nerddinner): <customErrors mode="RemoteOnly" defaultRedirect="/Home/Trouble"> <err...

Code First EF Deploy Attempt by Method failed

I have a asp.net mvc 2 on .net 4 with code first entity framework data access. When I deploy to one server it works beautifully, no prizes for guessing it doesnt work on the other...the message however I cannot understand Attempt by method 'System.Data.Entity.ModelConfiguration.Internal.Configuration.CodeFirstCachedMetadataWorkspace.G...

Unique Validation Attribute MVC 2

In my project I have several classes with properties that should be unique, and I want to write a custom attribute that can be used on all the properties. For example I have class User with property username and class Application with property name that should be unique and I want to be able to do this: [Unique(ErrorMessage = "Username...

jQuery + Ajax + Loading Spinner Image = Too Fast!

I'm using jQuery in my ASP.NET MVC 2 page. It's a super simple post that gets a date in return. The process itself runs very quickly. I want to use a spinner image to show the user something is going on. All works fine in Firefox, testing locally. However, in IE 8, the spinner image doesn't display long enough; it just flickers. Th...

How to deploy SQL CE 4 CTP to shared hosting?

How do I deploy SQL CE 4.0 with EF4 to a shared hosting provider for ASP.NET MVC 2.0? I've included System.Data.SqlServerCe.dll, and the amd64 + x86 directories in my bin folder, but keep getting a ".net provider not found". I realize it's currently in CTP, but this is just for testing purposes. My project + host is configured for .net ...

SimpleModal and mvc, calling page twice when opening in IFrame

Hi, i'm using asp.net mvc 2 and Simplemodal with iframe it works great but my controller is being called twice when opening in iframe when i call the page directly, the controller is called only once $.modal('<iframe id="frmDetails" src="' + src + '" >', { containerCss: { height: "90%", width: "90%"} }); is there an option that i'm ...

NerdDinner form validation DataAnnotations ERROR in MVC2 when a form field is left blank.

Platform: Windows 7 Ultimate IDE: Visual Studio 2010 Ultimate Web Environment: ASP.NET MVC 2 Database: SQL Server 2008 R2 Express Data Access: Entity Framework 4 Form Validation: DataAnnotations Sample App: NerdDinner from Wrox Pro ASP.NET MVC 2 Book: Wrox Professional MVC 2 Problem with Chapter 1 - Section: "Integrating Validation and B...

How to create an MVC 2 dropdown user control for use in multiple views

Hi, I'm new to MVC and the new paradigm hasn't clicked yet. I want to create a user control that is a simple dropdown and uses data from a database to populate its items. The dropdown would be useable in any view I chose. At this point I don't need the control to be data/table agnostic, I'd settle for making the user control strongly ty...

How can I do "causesvalidation=false" in ASP.NET MVC 2?

I have two buttons on a single form. One is used to submit the form while the other is used to search. I do not want the search button to trigger any server side or client side validation. How can I do this? Thanks. Edit I'm using Data Annotations on the server to validate, example: [Required(ErrorMessage = "Institution is req...

Wrapping an element with Html.ActionLink..?

I'd like to wrap a span with an action link because I'm adhering to an existing CSS theme. It doesn't look like any of Html.ActionLink's constructors allow for this. Possible solutions: A way to achieve this with existing helper? Derive & override ActionLink with new custom html helper? If #2 is the only way I have two questions. ...

JQuery Autocomplete and ASP .NET MVC database as data source

Hello, I have got this working with a local data source but not remotely. It uses the Jquery library and I have followed the instructions on the Jquery UI site. This is the code I have (which does not work). Can anyone a) amend this code to work b) show code of a working example?? Thanks: JQUERY $('#countries').autocomplete({ ...

ASP.NET MVC One Form, Two Buttons

I have a simple form based off a model called Visitor. I'd like to have a search button by one of the id text fields so the user can click the button and have the page populate with visitor information: first name, last name, etc. In Web Forms I would do something like this: page_load(){ person = businessManager.FindPersonById(Con...

is there a formula to calculate recurrence

I'm using ASP.Net MVC2. I would like to know if there is there a formula to calculate recurrence date? So from my client side I'm selecting dates and using ajax.post to send to the controller. My expecting result would be like so for example: maxdate is September 30th currentdate is today duration is 3 days for every week so output wo...