asp.net-mvc-2

ASP.NET MVC Custom Error Handler determine area/controller/action

In using the global error handler technique described here, http://stackoverflow.com/questions/1171035/asp-net-mvc-custom-error-handling-application-error-global-asax I want to log what area/controller/action was in effect when this error occurred. However, when putting a line in Application_Error such as: var controller = ViewContex...

Asp.net MVC 2: Understanding CRUD, specfically actions Create ( there are 2)?

Hi there, Can anyone tell help me understand the new CRUD scaffolding that is included with MVC 2? Let me explain, for example below you have 2 Create Actions... Now i presume that if i have the form "Post to itself" then the second with Attribute POST is executed - IS THIS CORRECT? so a form within a view that when Submitted submits...

Can't acces my Portable Area in MVCContrib MVC2

Hi, I need help. I can't access my portable area from my main project. I build everything and I get a 404 error when trying to access this portable area (localhost:123/IW/Home), but all my regular areas are working fine (ex: localhost:123/Portal/Home) Here's what I did in order to install my portable area -I downloaded MVCContrib -I add...

Silverlight 4 Business Application or ASP.NET MVC 2?

Hello: Wondering whether it is advisable to develop web applications under the "Silverlight 4 Business Application" template or under the "ASP.NET MVC 2 web application" template. In any case, what are the PROS and CONS? Thank you. ...

creating dropdownlist from ViewData

Does anyone have any idea why the code below doesn't give me any value but instead gives me "System.Web.Mvc.SelectListItem"? If I don't do a foreach but instead substitute the ViewData with this <%= Html.DropDownList("PersonOnCallCheckBoxList") %>, I get the correct value. Please help. foreach (var person in ViewData["Person"] as IE...

ASP.net MVC displaying results from two tables on one view

Hello I'm crating a simple MVC app that has People and Notes tables. Using the repository method and LINQ to SQL to access the data. Each person has a single note for a day and the note has a CreatedAt. Foreign Key in Note table as PersonID. I have managed to get CRUD working for both Person and Note independently but I'd like to be ...

Using a CSS File for site localization.

Hey guys, I'm creating a website with ASP.net MVC 2.0 which uses two different languages (English and Persian). what I want to is I need two have different layouts for these languages, English has a left to right and Persian has a right to left layout. What came to my mind was, if I could have two different css files like when you do i...

Saving JQuery Sortable (new order) to ASP.Net MVC controller?

I've implemented JQuery sortable, and it works fine. The problem is I can't pass the list in its new order to a controller so i can save it. <script type="text/javascript"> $(document).ready(function() { $("#sortable").sortable({ axis: "y" }); }); $(function() { $("#submit-list").button(); ...

ASP MVC 2 Validation : Passing Javascript code to the client

I am writing a custom validation attribute It does conditional validation between two fields When I create my rule, one of the things that I could not solve is how to pass javascript code through ValidationParameters Usually, I just do ValidationParameters["Param1"] = "{ required :function(element) { return $("#age").val() < 13;) }" Ho...

How do you submit objects with a many to many relationship using the Entities Framwork?

This is a follow up question to this question I asked yesterday. I've tracked down exactly the issue I think is causing me grief and I think I can explain the situation with more clarity. I just can't seem to figure out how to write objects with a many to many relationship to a SQL database using the Entities Framework in a C# ASP.NET M...

How can I allow period and comma as valid decimal point separators for floats?

I would like to allow both "123.45" and "123,45" as valid decimal inputs but currently "123.45" results in "The value '123.45' is not valid for Foo". ...

ASP.NET MVC 2: Using ImageRouteHandler to work on server subdirectory

I have an ASP.NET MVC 2 project where I built a custom ImageRouteHandler, following this blog: http://www.phpvs.net/2009/08/06/aspnet-mvc-how-to-route-to-images-or-other-file-types/ It all works great when I test it locally, but after I deploy it to a subdirectory of the root folder on my webserver... all the images are still referenced...

How secure Elmah?

Hi I am wondering how to actually secure elmah in my situation. I know you can disable remote connections(what I done) but how about for me I still want to be able to connect to it remotely just not anyone else. Usually if I wanted to look at elmah errors I would just load up the site on local host with my live db in my web.config so I...

RedirectToAction returns wrong url

I have the following View structure: Home Index Security Accounts LogOn The following code in the LogOn action causes a redirect to http://localhost/Security/Home/Index instead of http://localhost/Home/Index return RedirectToAction("Index", "Home"); Here is my Route registration code for each: Home routes....

Need To Access ViewData on MasterPage... or other options

I am using MVC2 in VS2010 with .Net 4.0. I have a situation in which I will have a bunch of partial views that I need to all have the same template. Basically I need them all wrapped with the same DIV (and other junk). I just want one place to change this DIV... so I used a master page. It works great, all the partial views use that ...

Source control/ASP.NET MVC 2 maintenance - from Win7 laptop to IIS7 production server

First, I'm not sure if I should break this question into smaller, individual questions. They're related, but I'm not sure if I'm doing it wrong. Apologies if I am. I'm a bit new to the idea of source/version control. I have installed TortoiseSVN on my development laptop, but haven't really gotten into the habit of using it. That sai...

What is the preferred way to set foreign relationships for an entity?

Product product = new Product() { Category = category }; _session.CommitChanges(); vs. Product product = new Product() { Category.ID = category.ID }; _session.CommitChanges(); What is the difference? Which one to use? Both seem to be valid and get correctly saved in the database. ...

ASP.MVC ValidationSummary on success

ValidationSummary can easly display error messages. But how can I make it a success message I return from my action. I am calling this action within Ajax request. Any idea? ...

CompareAttribute validator?

Validation attributes are realy nice. But what if I have to compare one property to another. How can I implement that? Scott has a great example for Email attribute validator at http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx but it's bind to only one property. What if I need to compare one date to...

How to get a common element (like Version number) into Site.Master?

Hi guys, Suppose I have a Site.Master page. I want to display something like the version number of the application (lets assume it is available in the the BaseController as a string) in the Site.Master. What would be the best way to do that? I know one way would be to have a Base view model class which would contain the version elemen...