asp.net-mvc-2

Comparison operators not supported for type IList when Paging data in Linq to Sql

I can understand what the error is saying - it can't compare a list. Not a problem, other than the fact that I don't know how to not have it compare a list when I want to page through a model with a list as a property. My Model: Event : IEvent int Id string Title // Other stuff.. LazyList<EventDate> Dates // The "problem" prop...

asp.net mvc 2 - return JavaScript with View

Hi, using ASP.NET MVC 2 I have a navigation menu inside my Master Page. In the navigation menu, I am trying add a class to the that the current page relates to (i.e., home page will add class="active" to the Home button). I'm trying to consider scalability and the fact that I don't want to change individual pages if the navigation chang...

CS0012: The type 'System.Web.Routing.RouteValueDictionary' is defined in an assembly that is not referenced.

I got this error using a new "ASP.NET MVC 2 Empty Web Application" project: CS0012: The type 'System.Web.Routing.RouteValueDictionary' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. ...

ASP.net MVC 2 and MonoDevelop 2.2

Is it possible to utilize MVC 2 from MonoDevelop 2.2 (using Mono 2.4)? If so - is it as simple as grabbing a reference to the new System.Web.Mvc or is there something else to consider? I realize that any templating support in MonoDevelop may not be 100% there since it was built to utilize MVC v1 (at least as of MonoDevelop 2.2). If any...

How to check if the model is dirty in the controller when posting back from view (asp.net mvc 2)

I have a model called 'Project' with a field called 'status'. If the user changes any data in the view, I need to change the status value. How do I check in the Controller to see if the model coming back from the view is dirty? Thanks! ...

What version of DataAnnotations is included with ASP.NET MVC 2 RTM

I'm working on a project using Visual Studio 2008 and have moved from the the MVC 2 Preview to RTM version. We would like to use model validation such as: public class ViewModel { [Required(ErrorMessage="UserName is required.")] [StringLength(10, ErrorMessage="UserName cannot be greater than 10 chars.")] public string UserN...

How do I control the DisplayForModel method in ASP.NET MVC 2?

If I use DisplayForModel in a strongly-typed ASP.NET MVC 2 View with an EntityObject model, then unwanted field labels are displayed: EntityState EntityKey How can I control the output to hide these? ...

Red border around TextBox when validation fails

I am using ASP.NET MVC 2. Html.DropDownListFor and Html.TextAreaFor automatically get red borders when the validation fails. How to make the four borders of a TextBox (using Html.TextBoxFor) red when it fails validation? For example, I have a TextBox that is required and when the user submits the form without specifying a value in the...

IntegrationTests - A potentially dangerous Request.Path value was detected from the client

I get this error: A potentially dangerous Request.Path value was detected from the client (?). when this URI: http://www.site.com/%3f. How can I write an integration tests around of all of this type of errors? I want to test against all this erros: A potentially dangerous Request.Path value was detected from the client A potentially ...

Handling Model Inheritance in ASP.NET MVC2 & NHibernate

I've gotten myself stuck on how to handle inheritance in my model when it comes to my controllers/views. Basic Model: public class Procedure : Entity { public Procedure() { } public int Id { get; set; } public DateTime ProcedureDate { get; set; } public ProcedureType Type { get; set; } } public ProcedureA : Procedure ...

Ideas - storing jquery parameters for later use in partial view

Ok, let me try to clearly explain what I'm attempting to accomplish here. Basically, I have a site that is using a liberal dose of jquery to retrieve partialviews into a consolidated 'single view'. So far so good - it all works great and is very performant. However, I would like to have the ability to 'flag' (using a button) any such ...

ASP.NET MVC list pull rendering technique

Hy, i went from this page on internet http://studiostyles.info/schemes that have a particular rendering technique, the list grow when the page is rendered. Is there anyone that can explain me how it is possible? Thanks in advance. F. ...

Unit Testing (xUnit) an ASP.NET Mvc Controller with a custom input model?

I'm having a hard time finding information on what I expect to be a pretty straightforward scenario. I'm trying to unit test an Action on my ASP.NET Mvc 2 Controller that utilizes a custom input model w/ DataAnnotions. My testing framework is xUnit, as mentioned in the title. Here is my custom Input Model: public class EnterPasswor...

ASP.NET mvc 2 Validation always shows errors on initial page load.

I've searched around a lot, and honed this problem down to this case: I'm using the PRG pattern, pragmatically I'm using the same DTO for my post/get actions. It looks like when I have the dto with the data annotation attributes in the get action parameter list, the validation is always displaying errors, every time on initial page load....

Problem with Validate Anti Forgery

Hi! I have a problem regarding MVC Anti forgery token. When I do my authentication I have pseudo code like this: var user = userRepository.GetByEmail(email); System.Threading.Thread.CurrentPrincipal = HttpContext.Current.User = user; by doing so I'm able to get the current user in my code like this: var user = HttpContext.Current.Use...

Persisting querystring parameter throughout site in ASP.Net MVC 2

http:www.site1.com/?sid=555 I want to be able to have the sid parameter and value persist whether a form is posted or a link is clicked. If the user navigates to a view that implements paging, then the other parameters in the querystring should be added after the sid. http:www.site1.com/?sid=555&page=3 How can I accomplish this in As...

Does the DataAnnotations.DisplayAttribute.Order property not work with ASP.NET MVC 2?

I set values for the Order property of the Display attribute in my model metadata. [MetadataType(typeof(OccasionMetadata))] public partial class Occasion { private class OccasionMetadata { [ScaffoldColumn(false)] public object Id { get; set; } [Required] [Display(Name = "Title", Order = 0)] ...

ASP.NET GetFullHtmlFieldId not returning valid id

In MVC2 template, I normally use this.ViewData.TemplateInfo.GetFullHtmlFieldId(fieldName) to generate the id field of an html element. This has worked in most of the cases. However this method does not actually return valid id field, it merely prefix fieldName with ViewData.TemplateInfo.HtmlFieldPrefix, this is causing problems for me w...

The default DisplayTemplates views of ASP.NET-MVC2 are not compiled

Some of the default DisplayTemplates and EditorTemplate views of ASP.NET-MVC2 are not compiled. Why and what to do you do to get them fixed. ...

Prevent change of hidden field

What if I have ChangePassword form with hidden ID field of the user. BadPerson knows id of GoodPerson. He opens Change Password form with FireBug, changes his Id to GoodPerson's Id, so password changes for GoodPerson. Of course I can create some server logic that will prevent this, but I think there should be some out of the box solut...