asp.net-mvc-2

ASP.Net MVC 2 Model Validation Regex Validator fails

I have following property in my Model Metadata class: [Required(ErrorMessage = "Spent On is required")] [RegularExpression(@"[0-1][0-9]/[0-3][0-9]/20[12][0-9]", ErrorMessage = "Please enter date in mm/dd/yyyy format")] [DataType(DataType.Date)] [DisplayName("Spent On")] public DateTime SpentOn { get; set; } But whenever I call Mod...

SwfUpload and jquery .show and .hide

I'm trying to get swfUpload to work in my application for file uploads. It works, but I want to show the file upload only if the user clicks on a button (for design reasons, and because I need to have other values available on the page before this upload is created). But in order to wait to show this upload, I have to hide the form with...

DatabaseFileLockedException driving me crazy

I am following the example here: http://developer.db4o.com/Forums/tabid/98/aft/10114/Default.aspx to setup my MVC2 app with db4o using an HttpModule. I also have a LINQPad instance open to query the data as I develop. The web app seems to work like a charm, but LINQPad keeps getting DatabaseFileLockedExceptions until I close down the w...

Multiple URLs and single codebase with ASP.NET MVC

Hey, I'm pretty new to ASP.NET MVC and I just want ask of this scenario is possible and, if so, could anybody provide any resource links on how to implement it. Say I have a site that can be accessed from www.mysite.com, can I also have the same site load up through www.mysite2com, www.mysite3.com and so on? effectively providing the a...

How to route a query string with "?" and how to handle it

In my global asax file, I want to map a route such as this: http://domain.com/add/link?url=http%3A%2F%2Fgoogle.com And then catch it using my LinkController with action called Add. Do I do this? global.asax-> routes.MapRoute( "AddLink", "Add/Link?{url}", new { controller = "Link", action = "Add" } ); LinkController-> ...

ASP.NET MVC - Populating a form dynamically through the database

I am porting a search application from Classic ASP to ASP.NET MVC2. One of hte pages is a dynamically populated search form that is broken up into 4 categories, each with 2 rows. The client is able to uncheck options for each of these categories. When this happens, each category is dynamically repopulated top to bottom, left to right....

ASP .NET MVC Webpage Cannot Be Found

I cannot get ASP .NET MVC 4.0 to work when deployed on IIS 7.5 (Windows 7 x64) in Integrated Mode (or any other mode for that matter, but let's focus on Integrated Mode). I am following these very simple steps Create a new ASP .NET MVC 2 Web Application Hit Run. It works. Edit the project configuration to use my local IIS web server (...

File download in Asp.Net MVC 2

I want to enable file download in my MVC application, without simply using a hyperlink. I plan to use an image or the like and make it clickable by using jQuery. At the moment I have a simple just for testing. I found an explanation of doing the download through an action method, but unfortunately the example still had actionlinks. No...

Improving urls in asp.net mvc2

Improving urls Currently I have links in the form (displaying product information): http://localhost:XXXX/Products/?page=1 I want to clean this up into the form: http://localhost:XXXX/Products/Page1 I think I need to do this with routes.MapRoute, something like so: routes.MapRoute(null, "/Products/Page{page}", new {controller = "P...

Asp.net mvc 2 model binders what's behind scene

Hello, Im starting with MVC2 and i have a simple question: If i have a typed view with a form inside, and this textbox created with lambda expressions: <%: Html.TextBoxFor(e => e.Name)%> When i submit this form the default model binder take the request form, takes the model typed to the view, serialize the data posted (as a this m...

In AutoMapper, is it possible to determine what the destination property name would be for a particular source property.

Note: the question relates to the mapping meta-data, not the mapped values. i.e. what is the NAME of the target mapped property, not the mapped value. Background: I'm using MVC 2 with automapper to map between domain entities and view models. I have some validation rules at the domain level which are defined in the domain model, and s...

ASP.NET MVC 2 technique to hide a part of a view based on user permissions

Hello, What's the best technique to hide part of a view depending of the credentials of the user? To explain my self little better and as example i have the following code in my view: <%= this.Model.Name %> <%=Html.ActionLink("Edit",....)%> And i would like to hide the edit button for those that aren't administrators for instance.....

HtmlHelper using ViewContext.Writer not rendering correctly

Hi, I am building a simple CMS with asp.net MVC and I have almost all the parts working. I have one minor issue which I can't work out how to solve. I have a Html helper method that renders the content of area. This method however uses the Response.Write to write its content rather than returning a string. The reason for this is that I'...

Update a document in RavenDB

I am using asp.net MVC2. I have a model defined as public class Department { [ScaffoldColumn(false)] public object Id { get; set; } [Required(ErrorMessage = "Department Name is required")] [StringLength(25)] [DisplayName("Department Name")] public string Name { get; set; } [...

Handling server-side validation with Ajax forms and ASP.Net MVC

Hi, Before down-voting or closing for duplicate questions, I want to make clear that I have read old posts on this site and others. The problem is that they are old (some at least) and are not giving really good examples. I currently use ASP.Net MVC 2.0 with Ajax.BeginForm and jQuery Validation client-side validation which both works p...

UpdateModel with Dictionary/Hashtable

I'm trying out some MVC stuff and I was wondering if there's some way to edit dynamic fields. So to try this I added a keyed collection called CustomFields. I've tried both Hashtable and Dictionary. In the view I then wrote: <%:Html.TextBoxFor(model => model.CustomFields["x"])%> This then generated this HTML: <input id="CustomFields...

Sending Email from Windows Azure Through BPOS

I'm trying to send an email via asp.net mvc2, and all works well on our companies mail server. However, we're looking to switch to using our client's BPOS account. This works fine locally, but when deployed to azure, we're getting some timeout errors. Can anybody confirm I have the following correct? SmtpClient smtp = new SmtpClient("...

MVC 2 and ASP.NET 4 Request Validation Exception

I am working on an application that I inherited from another dev shop that I recently upgraded to MVC2/.NET 4 from MVC 1/.NET 2/3.5. Everything is working fine with the exception of one page. On this page there is an iframe that loads up an instance of TinyMCE and allows for inline editing of some HTML templates. On the hosting page t...

RavenDB index doesnt show new data

I have a model defined as public class Department { [ScaffoldColumn(false)] public object Id { get; set; } [Required(ErrorMessage = "Department Name is required")] [StringLength(25)] [DisplayName("Department Name")] public string Name { get; set; } [DefaultValue(true)] ...

ASP.NET MVC 2 Data Validation: Does this carry from a DomainModel to a ViewModel?

Given my understanding of MVC and DDD (critique as necessary): Domain Models can be created by Factories, and persisted by Repositories. These are POCO objects. View Models contain partial or complete Domain Models as needed by the view. They are generated by a service that interacts with a repository. Thus Domain Models never make ...