asp.net-mvc-2

asp.net mvc 2: Overriding client validation so i can use jquery effects?

Hi there, is there a way to override client validation so i can use jquery? Currently i am using attributes on my model, a new feature of mvc 2 Thanks in advance ...

ASP MVC 2 in Sharepoint 2007 Security Exception

Hello Everyone, I am trying to configure ASP MVC 2 Framework to run within a SharePoint 2007 install on IIS 6.0. I have managed to get the two web.config setups together, and made GAC and global.asax changes. When I try to access the MVC application within the SharePoint domain (http://Sharepoint.com/MVCApp), I get a security exceptio...

MVC 2 Templates - Is it possible to redirect the current editor template to its display template based on metadata?

For a project I'm working I've been asked to redirect an editor template to its display template based on metadata that is provided with the model. Now I was looking at a way to do it before it hits the editor template but that seems to cause more issues than it is worth, at least with how the system has been architected. The simplest ...

Caching Entity Framework EntityTypes

Hi, I have EntityTypes generated from a database using Entity Framework 4. I would like to use Cache to store some of these EntityTypes for performance reasons. Is it safe to do the following provided that the object will be used for read-only actions: context.Students.MergeOption = MergeOption.NoTracking; var students = context.Student...

ASP.NET MVC 2 - Html.EditorFor a nullable type?

I have two editor templates: one for decimal, and one for decimal? (nullable) But when I have a nullable decimal in my model, it tries to load the normal decimal editor: <%: Html.EditorFor(model => model.SomeDecimal )%> <%: Html.EditorFor(model => model.SomeNullableDecimal )%> The first one works fine, and loads the decimal editor te...

asp.net mvc - MicrosoftMvcAjax.js throws javascript error when updating table elements in IE8

In IE8 or anything older, innerHTML is not supported on certain elements like TR & TD. Unfortunately, the MicrosoftMvcAjax.js file included in the MVC 2 project uses innerHTML for the Ajax update method within the Ajax.BeginForm or Ajax.ActionLink. To fix that, look into Line 18 of MicrosoftMvcAjax.js and replaced it with this: Sys.Mvc...

Problems with dropdown list selected item asp.mvc2

After validation dropdown list do not select previose value. <%: Html.DropDownList("Country", (SelectList)ViewData["Country"],"") %> However in Quick View there is correct selected value. :( ...

MVC 2.0 dynamic routing for category names in an e-store

Hi guys! I'm currently working on an e-store using ASP.NET MVC 2.0. I already got most of it up and running, but the part that's been bothering me is routing. I want this: http://mystore.somewhere/my-category-1/ So far I've been able to solve it by using: routes.MapRoute( "Category", "{alias}/{pageNumber}", ...

ASP.NET MVC as a RESTful Service and TransactionScope.

Hi, I'm considering using the MVC 2 Framework as the primary service for a project I'm working on, currently, we're using a WCF based service which works well because I can wrap a TransactionScope on the client and make several calls and be sure that the transaction is successfully transferred to the service. Is that possible using the...

Trying to save output from RenderPartial to a Javascript variable and use it later.

In my Create View: <script type="text/javascript"> var tabContent = "<% Html.RenderPartial("ProductEdit", new Web.Model.Product()); %>"; </script> Unfortunately this seems to break. At least the quotes (") aren't escaped (\"). How could I "inject" the results of RenderPartial into JS? ...

dotnetopenauth asp.net mvc2 project template - broken when running from localhost:xxxx

So I create a new dnoa mvc2 site from the template, run setup.aspx without issue, login and authorize my openid - all ok, but on the redirect to http://localhost:18916/Auth/PopUpReturnTo?dnoa.uipopup=1&dnoa.popupUISupported=1&index=0&dnoa.userSuppliedIdentifier=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid&dnoa.op_endpoint=https%3...

Fluent NHibernate not querying the database correctly

Hi, i have just looked into hooking my application into nhibernate (fluent nhibernate) but i am having a few difficulties... I have tried to follow what people have done and found this: public class NHibernateSessionPerRequest : IHttpModule { private static readonly ISessionFactory _sessionFactory; static NHibernateSessionPer...

How to use non-static enum values with the DefaultValue data annotation?

public enum ProductQuantityType { Weight = 1, Volume = 2, Custom = 0 } This fails [MetadataType(typeof(ProductMetaData))] public partial class Product { public class ProductMetaData { [DefaultValue(ProductQuantityType.Weight)] public object QuantityType { get; set; } } } Error: An object reference...

ASP.NET MVC2 Model Binding does not POST back hidden values

I have a /Register [GET] Action in the controller that pre-poluates a view-model with a string and an integer and returns: return View(myModel); I can see the string being populated in the textarea and the id being populated in a hidden input. Yet when the form gets POSTed, the string value is null and the int value is 0. I verified tha...

How to support multiple forms that target the same Create action on the same page?

I want to have two separate forms on a single create page and one action in the controller for each form. In the view: <% using (Html.BeginForm()) { %> // Contents of the first (EditorFor(Model.Product) form. <input type="submit" /> <% } %> <% using (Html.BeginForm()) { %> // Contents of the second (generic input) form. ...

ASP.NET MVC - Is there an easy way to add Data Caching to my Service Layer?

I've got my MVC application wired up so that the Repository Layer queries the LINQ to SQL classes, the Service Layer queries the Repository Layer, and the Controllers call the Service layer. Basically I have code as follows Repository Public Function GetRegions() As IQueryable(Of Region) Implements IRegionRepository.GetRegions ...

MVC 2 Areas not showing up in VS2008 context menu

I have converted my ASP.NET web forms project into an MVC project by adding the MVC ProjectType guid in the project file. All of my MVC 2 project items are showing up (View, Controller etc.) but for Areas. I have MVC 2 installed so I'm not sure what's not setup right. ...

Asp .net mvc 2 forms authentication not working on iis 6. Need helps determining correct routes.

I'm trying to setup Forms Authentication in an asp.net mvc 2 application that will be hosted on IIS 6. There's an issue somewhere in my routing, but I can't pinpoint exactly where it is. Here is the route entries I'm using to route the mvc requests through the aspx processing on IIS 6. These may or may not be the "right" way, but they d...

Parent Controller Class in ASP.NET MVC 2

Hey everyone, I've been working on a rather large web application that requires a specific id param in the url for every page visited (for example, /controller/action/id?AccountId=23235325). This id has to be verified every time someone visits a page. I want to reduce code replication as much as possible, and was wondering if there i...

ASP.NET MVC - Pass Json String to View using ViewData

I'm trying to pass Json to my View using ViewData Controller ViewData("JsonRegionList") = Json(RegionService.GetActiveRegions()) view $("input#UserRegion").autocomplete({ source:"<%: ViewData("JsonRegionList").ToString %>", minLength: 3, but the problem I'm running into is the output source ...