asp.net-mvc-2

Providing the path to an image stored on the server, not in the application files

I need to display images on my ASP.NET MVC page that will be stored on the server i have an apphelper class that I can use to provide the path like this public static class AppHelper { public static string ImageLowResPath(string imageName) { } } How can I get the file path that is stored on the c: drive of the server...

How do I add a confirmation popup on a button (GET POST action in MVC)?

I have a get/post/JSON function on an aspx page. This page adds data entered in a textbox to a table populated by javascript. When the user select the submit button. If the textbox is not empty, have a popup button telling the user the data in the textbox is not saved in the table. How do I have a confirm "ok/cancel" popup display on ...

Localization with separate Language folders within Views

I'm trying to have specific folders for each language in Views. (I know this isn't the best way of doing it but it has to be this way for now) e.g. /Views/EN/User/Edit.aspx /Views/US/User/Edit.aspx These would both use the same controller and model but have different Views for each language. In my Global.asax.cs I have routes.Map...

ASP.NET MVC2: Can you get ModelMetadata.ContainerType from within a collection?

I'm trying to call DisplayFor and DisplayForModel to iterate an IEnumerable<> with various element types from within a view. I have Templates defined for each element/Model type. What I would like to do is check the ViewData.ModelMetadata.ContainerType from within the Template so that Template can determine if it was called as part of a...

MVC Html.textbox/dropdown/whatever won't refresh on postback

OK, let's start with the Html.Textbox. It is supposed to contain text read from a file. The file read is based on what the user picks from a dropdown list. The first time it is fine. The user picks a value from the dropdown list. The controller uses that value to read some text from a file, and returns that text to the view via the view...

How to prohibit the use of offensive words in usernames during registration

What is the best practice? Any samples? I did a search and could not find anything. I am thinking an Xml file with prohibited words which I could check against during registration and also be used elsewhere on the site to check for prohibited words. The easy and quick way I thought was in the AccountModel.cs file and adding an attribut...

How to create a reusable Asp.Net Mvc application?

We have multiple Asp.Net WebSites each running on IIS. Site1 : http://www.Site1.com/ Site2 : http://www.Site2.com/ We have to implement Shopping Cart functionality for each of the above WebSites. For each web site the corresponding shopping cart should work on the following Url. Shopping Cart for Site1 : http://www.Site1.com/...

Html.EditorFor not updating model on post

I have a complex type composed of two nullable DateTimes: public class Period { public DateTime? Start { get; set; } public DateTime? End { get; set; } public static implicit operator string(Period period) { /* converts from Period to string */ } public static implicit operator Period(string value) { /* and back again *...

How to get the checked checkbox from a ASP.NET MVC2 form

I have a hard time in asp.net MVC2 trying to get the checked values of different checkbox. Here is my view <div id="RoleSelection"> <ul> <% foreach (var roles in Model.Roles) { %> <li> <input type="checkbox" name="roles" value="<%: roles %>" /> <%: roles %> </li> <...

[Asp.Net MVC] Encoding a character

Hi, I am experiencing some weird encoding behaviour in my ASP.NET MVC project. In my Site.Master there is <div class="logo"> <a href="<%=Url.Action("Index", "Win7")%>"><%= Html.Encode("Windows 7 Tutoriál") %></a></div> which translates to the resulting page as <div class="logo"> <a href="/">Windows 7 Tutoriál</a></d...

Why does not Asp.net mvc application work on Asp.Net Classic Application Pool?

I have an Asp.Net MVC 2 web application deployed on IIS 7.5 on .Net 4.0. When I select application pool as Asp.Net v4.0 Classic I get the following error. HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory. The same application works fine when I select application pool as Asp.Net v4.0...

Error converting anonymous (htmlAttributes) to IDictionary in custom helper

I'm trying to use a custom helper that creates a link using the example found at http://stackoverflow.com/questions/675319/is-there-an-asp-net-mvc-htmlhelper-for-image-links. Going on the assumption that this code actually functions, I'm not sure what the problem is. I'm new to anonymous types and MVC, so am assuming I'm missing somethi...

FormID not populated in jquery client-side validation when using strongly-typed BeginForm?

I have been migrating a site from MVC1 to MVC2 for the last couple days. We chose to use the Jquery client-side validation. At one point my BeginForm statement looked like this ... <% using (Html.BeginForm("Index", "Trial")) { %> ... and everything was working well. Then I changed my BeginForm to use a strongly-typed variant: <%...

How can you share a master page between 2 different projects/apps in ASP.NET MVC?

Is there a way to share a master page between different MVC projects/applications? We have several different applications, and would like those apps to share a similar header and footer on the web pages. What is the best approach to handle this situation with ASP.NET MVC? ...

Using Profile and CreateUserwizard in ASP.NET MVC 2

Hello, I am using this tutorial to create an application in ASP.NET MVC 2 where I can register users with custom profile properties using the CreateUserWizard control. My problem is that the tutorial uses ASP.NET (not MVC) and it needs the code-behind of the control for handling the CreateUserWizard1_CreatedUser method. Since in ASP.NE...

Using unity to decouple business logic layer from data access layer

I have implemented Unity within my Asp.Net MVC2 project. I am currently registering my BLL types on Application Start. Then I created a class called UnityControllerFactory that is in charge of resolving my dependencies within my controllers. I am simply using Property injection to accomplish this by using the dependency attribute. ...

setting more than one RouteConstraint on route parameter

here are code I'm using to do, but compiler says: An anonymous type cannot have multiple properties with the same name context.MapRoute("RouteName", "statics/category/{fileName}", new { controller = "myController", act...

Form to add products to the database on asp.net Mvc2

Hello, Its my first time with asp.net MVC 2. Im came from asp.net webforms. I would like to know how to build a form to add products (for instance) to a database with client and server validation. Do you have any url useful that explains this? Thanks in advance. Best Regards. Josema. ...

Asp.Net MVC Combine and remove inline scripts during response.

I have been doing some performance analysis on a few websites I am working on and I am noticing that a big problem is the inline scripts. For the external scrips I wrote an http handler which combines, minifies, and gzips the javascript into one file. This is then stored for reuse later by hashing the filenames. What I am wondering (...

MVC2 + ASP.NET 4.0 + IIS6 + extensionless URLS, no longer need wildcard mapping?

I noticed that asp.net 4.0 now installs a top-level isapi plugin (in iis6), such that it can inspect every request coming to the server. Should this now allow us to run MVC applications with extensionless URLS and have the aspnet isapi process them correctly without requiring the wildcard mapping (and avoid the performance penalties asso...