asp.net-mvc-2

Redirect in FileAttribute's OnActionExecuting not properly working

I have an action called EditProfile. To secure it I have added a class RequireUserLogin inherited from ActionFilterAttribute. In the OnActionExecuting, when I redirect user to login page, before going to login page, it first execute the EditProfile action code (which i don't expect) and than redirect the user to login page. I want to not...

ASP.NET MVC2 RC : How to intercept or trigger client-side validation before ajax request?

I have a username textbox on a form, that has a few validation rules applied to it via the DataAnnotation attributes: [Required(ErrorMessage = "FTP login is required")] [StringLength(15, ErrorMessage = "Must be 15 characters or fewer")] [RegularExpression(@"[a-zA-Z0-9]*", ErrorMessage = "Alpha-numeric characters only")] public string Ft...

JQuery - $ is not defined

I have a simple jquery click event <script type="text/javascript"> $(function() { $('#post').click(function() { alert("test"); }); }); </script> and a jquery reference defined in the site.master <script src="<%=ResolveUrl("~/Scripts/jquery-1.3.2.js")%>" type="text/javascript"></script> I have ch...

ViewModel approach interferes with ModelBinding in MVC 2 when using the new "For" HTML helpers

I am using .net MVC 2.0 and have set up an edit view that receives a custom ViewModel object. The ViewModel is a class with two properties: // Properties public Portfolio Portfolio { get; private set; } public SelectList slSectors { get; private set; } In my view there is a form with the purpose of updating the Portfolio Object. The...

setInterval stops after Ajax request

I'm using Asp.net MVC and I want my partial view to refresh on an interval, which it does until I make an unrelated Ajax request, then it stops. Here are a few simplified snips to illustrate the problem. in AjaxRefresh.js: function ajaxRefresh() { var f = $("#AjaxForm"); $("#AjaxLoading").show(); $.post(f.attr("action"), f...

Required Attribute for bool value type when used as checkbox

I'm running into a problem where I have a simple add/edit form and using client-side validation (jQuery/MicrosoftMvcJQueryValidation.js) which is generated from data annotations and enabled client side by calling the following in my view: <% Html.EnableClientValidation(); %> This seems to work fine for most elements, however I have an...

Why does ASP.NET MVC care about my read only properties during databinding?

I have a read only property on my 'Address' model 'CityStateZip'. It's just a convenient way to get city, state, zip from a US address. It throws an exception if the country is not USA (the caller is supposed to check first). public string CityStateZip { get { if (IsUSA == false) { ...

Problem with language specific resource files in a class library project.

I'm working on an ASP.NET MVC 2 application and use a seperate class library for my model. I used resource files in my class library project to embed validation messages and use it in my meta data classes and everything was Ok till I decided to add a new language to my project so I renamed Resource.resx to Resource.en-US.resx and also co...

Mvc2 validation summary and required metadata

source code... Thing is, if i specify required metadata using fluent modelmetadata provider like this=> public class Foo { public string Bar { get; set; } } public class FooModelMetadataConfiguration : ModelMetadataConfiguration<Foo> { public FooModelMetadataConfiguration() { Configu...

ASP.NET MVC 2 RC 2 "Wizard" for whole model validation

There is a good simple solution for a multi-page "Wizard" control in MVC here: http://www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx http://www.highoncoding.com/Articles/652_Creating_Wizard_in_ASP_NET_MVC_Part_2.aspx The model is populated in several steps and a hidden field is used to persist data bet...

Absolute path issue

I have an ActionResult in some controller and i want to return a view from another controller I am doing this: return View(VirtualPathUtility.ToAbsolute(@"~/Views/Order/Index.aspx")); I see that page (there is a jqgrid on it) but not fully loaded, jqgrid makes an ajax request to get the data but the request fails, thing which doesn't ...

How to pass an enum to Html.RadioButtonFor to get a list of radio buttons in MVC 2 RC 2, C#

I'm trying to render a radio button list in MVC 2 RC 2 (C#) using the following line: <%= Html.RadioButtonFor(model => Enum.GetNames(typeof(DataCarry.ProtocolEnum)), null) %> but it's just giving me the following exception at runtime: Templates can be used only with field access, property access, single-dim...

Do I need to uninstall RC1 before installing ASP.NET MVC 2.0 RC2?

I have an installation of ASP.NET MVC 2.0 RC1 which I am planning to upgrade to the newly released RC2. This upgrade path isn't mentioned in the release notes. Does anyone know if I can upgrade from RC1 or should I uninstall it first? I'd like to avoid any possible problems with the upgrade so if anyone has already done this and has an...

jQuery Ajax (beforeSend and complete) working properly on FireFox but not on IE8 and Chrome

I am using jQuery ajax version 1.4.1 in my MVC application (though the issue I am discussing was same with the old jQuery version 3.2.1) as well, to check during customer registration if the username is already registered. As the user clicks on the "Check Availibility" button, I am showing a busy image in place of the check button (actua...

ASP.NET MVC2 and DateTime Format

I am using ASP.NET MVC2 with MvcContrib.FluentHtml to do form binding. I want to bind a DateTime format to a textbox with specific datetime format. <%=this.TextBox(c => c.date_a).Class("readonly text-box") %> // PS. c.date_a is a DateTime gives me <input type="text" value="5/9/2009 12:00:00 AM" name="date_a" id="datea" class="reado...

ASP.NET MVC 2 | Linq To SQL | Many to Many Checkbox Management

I'm using the L2S designer to generate classes from my DB. The app is your average blog kind of thing. I have a many to many relationship between Posts and Topics with a table PostsTopics that links them. When editing a post I'd like to display a checkbox for each topic and pre-check the ones for which there are values in the PostsTop...

Progressive Loading, ASP.NET MVC

I have a page that has to render a huge set of query results - most of them with very, very small images. It is already paginated, so that won't solve my problem. The query executes fine - it's very zippy, returns in about .0004 seconds, paginates itself out to the View - all is well in the land of Oz. However there is some big trouble...

ASP.NET MVC 2 Widgets

Hi, is it possible to create kind of widgets that are pluggable in ASP.NET MVC? I'd like to give my users the option to upload and attach a widget that I provide (ie. zip format). Recently I thought about deploying Areas in different project assemblies. Is it still possible with MVC RC2 (later RTM) and is there an option to dynamically ...

ASP.NET MVC 2 Dynamic Layout

Hi, how would you guys create a dynamic layout in ASP.NET MVC 2 where admins could select widgets to display, arrange them, disable, move them etc.? I mean a flexible layout that can be changed via the admin panel without having to touch the code. Here I thought about defining and storing layout widgets paths in a db. Later I could asso...

ASP.NET MVC 2: Breaking changes

What will be broken after migrate to MVC 2? I wonder what breaking changes will come with MVC 2, so how traumatic will be the migration? How much smooth have been your experience migrating? ...