asp.net-mvc-2

ASP.NET MVC 2 not displaying images in CSS files

I have a small app I've written, and it works well when using the dev server, but as soon as i switch to IIS on my local box (IIS 7), I lose images and styles. I tried using Url.Content and that kind of works for styles and images in the master page, but I still lose images that are referenced from CSS styles Is there any way I can ge...

Stepping through ASP.NET MVC 2 source

I've been trying to set up the ASP.NET MVC 2 RTM Source for use with my app, so I can step through things like model binding when debugging. However, I haven't been able to get it to work - I'm getting errors like: The type 'System.Web.Mvc.Controller' is defined in an assembly that is not referenced. You must add a reference to assemb...

what is the diffirence between these expressions in asp.net mvc views"<%: %>", "<%= %>"?

<%= %> I know that this means Response.Write but what is the meaning of ":" sign? ...

Can a Web User Control (.ascx) use a CSS file for styling?

Here's the source of a blank .acsx file I created called LogOnBox. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LogOnBox.ascx.cs" Inherits="ECommerce.Views.Shared.LogOnBox" %> I want to drag some labels, and textboxes etc and give them style using a CSS file. How can I associate a CSS to an acsx file? ...

ASP.NET MVC2 Creating ViewResults outside of controllers

Again an easy question for ASP.NET MVC 2. public ActionResult MyAction(MyModel model) { if (ModelState.IsValid) { // do great stuff and redirect somewhere else } // model has errors return View("~/Home/Index", model); } The question is that I want to return a view which is ...

Jquery validation - allow number without the leading zero?

I'm using jquery validation (http://docs.jquery.com/Plugins/Validation) like so: var $__field = $("#selector"); if ($__field.is(":visible")) { $__field.rules('add', { required: true }); $__field.rules('add', { number: true }); } If the user enters a number without a leading zero, eg .5 then jquery vali...

Pattern for specifying the "return" controller/action in an MVC2 application

Problem: Calendar application built using ASP.NET MVC2 From the main calendar page, the user can select an add appointment link that brings up a form to create a new appointment. After the appointment is created, we want to return to the main calendar page, potentially with an error or confirmation message. There are other pages within...

How to handle nested models in ASP.NET MVC

Hi all, I have been looking around for a nice working solution on how to correctly handle model binding with nested attributes. I have one model that has a list of other child models like below: public class Organization : IEntity { [ScaffoldColumn(false)] public int ID { get; set; } [LocalizedDisp...

How can I make ASP.NET MVC 2 persist submitted form values across multiple submits?

Say I have a strongly-typed view of ViewPage<Song> and some additional fields in the form of create/edit scenarios that are not directly part of the Song entity (because I have to do some parsing before I fetch the composers from a foreign table and create the bridge entities SongComposers). public ActionResult Create(Song song, string ...

Implementing Security in ASP.Net MVC2

I have a CMS application in which i want to apply security on user actions like user1 can have rights to add new page but doesnt have rights to delete that page im maintaining this rights in database. Please tell me what may be the best approach to implement security to this CMS ...

Validation based on other field?

In ASP.NET MVC 2, I have a Linq to sql class that contains a series of fields. Now I one of the fields is required when another field has a certain (enum) value. I've come so far that I wrote a custom validation attribute, which can take an enum as an attribute, but I can't say, for example: EnumValue = this.OtherField How should I do ...

Why are my checkboxes not binding to my View Model?

I have a view model for a business. This model conatains a view model for address, contact details and also an IEnumerable. I use editor templates to display the checkboxes. The problem is when I'm on the edit action and post the form the categories come back as null. I have read a few similar questions but havent found a solution that ...

ASP.NET MVC - can't get jquery to reload page after post delete

Following this writeup, http://haacked.com/archive/2009/01/30/simple-jquery-delete-link-for-asp.net-mvc.aspx, I'm having some difficulties actually getting my page to update after performing a delete with jquery. The delete works fine - the controller action is called, delete is handled, the object is in fact deleted. At that point the ...

Dynamically determine the name of the action I'm in from my controller base class in MVC2?

I need to dynamically determine the name of the action I'm in from my controller base class in MVC2 in my OnExecuting handler. So if the Controller is Foo and the Action is Bar, I want the string "/Foo/Bar". This seems like it should be pretty simple, but I haven't found anything when I STFW. I'm hoping either one of you is better at...

Weird ASP.NET MVC links with (A(anythingworkshere))

Google's webmaster tools has started showing some very strange internal links for my site. It appears "normal", but I'm not sure what to make of it. If you use parentheses and put in a single letter, then put literally anything in parentheses after that, the link works. I did a search for any other MVC sites so I could see if they had th...

This modelbinding from jquery, what's wrong with it?

I have the following action: public JsonResult GetGridCell(double longitude, double latitude) { var cell = new GridCellViewModel { X = (int)Math.Round(longitude.Value, 0), Y = (int)Math.Round(latitude.Value, 0) }; return Json(cell); } I'm calling it with the following jquery: $.post('Grid/GetGridCell', { longitud...

What are some alternatives to RedirectToAction?

On my HomeController I have an index action which redirects to the index action of the CustomerController via the RedirectToAction method. In this instance I don't like how RedirectToAction modifies the URL showing mysite.com/Customer. Are there some alternative mechanisms to performing a redirection that will allow me to still leverage ...

Custom authorization with MVC2 seems to have problem with IsInRole()

In my AccountController, I have code like this: ControllerContext.HttpContext.User = new MyAppUserPrincipal(user); When I step through this in the debugger I can see that ControllerContext.HttpContext.User.IsInRole("Admin") is true. Next, I have a HomeController protected by a custom attribute: [AuthorizeMyApp(Roles = "Admin")] In...

Using Generic Types with MVC2 Templates

I have a model class that is a generic type. I would like to create a custom editor template that would display it (and put it in the Shared folder). How can I do that? I can't figure out how to name it so that MVC2 would pick it up over the generic template. Additionally I am wondering if there is a way to explicitly specify which t...

should i use asp.net membership system or not?

I developing a network that uses membership. I have a couple of stories that i have to implement. and i want to use to entity framework with MVC 2 to build this site. asp.net membership system has really really nice features. but is it hard to extend? i dont know. one of these: i want to give each users to a uniq name that users can use...