asp.net-mvc-2

ASP.NET MVC 2 server-side validation for ajax form

Hi all! I've faced the following problem. I'm developing a form for the site and this form should have validation. I wanna to use native ASP.NET MVC 2 validation functionality but get stubborn with it. I have a form that is loaded via $.get and displayed using jQuery UI modal dialog. All examples I found explains how to use MVC validati...

Clearing Asp.net MVC cache for i.e

I have MVC 2 site, and I.E is cacheing word documents linked on my site. I know there is a way to clear cache before every action in the controller. But for these links i am not using action, i am just creating regular href links.. Is there anyway i can clear the cache? ...

Restrict Area to a given role

I have an area setup in MVC2, called Admin/, which I want I only want Users who belong to the role "admins" to have access. I know I can decorate each of the methods with [Authorize(Roles="admins")], but this seems tedious when your talking about multiple controllers with multiple actions. Is there an better and cleaner way? ...

ASP.Net MVC - Sending an object from controller to view to controller

Hi everybody, I'm just starting with ASP.Net MVC 2 and might be doing something wrong. I have a controller who builds some objects and passes them to a view using ViewData. In the view I display the data etc ... and then want to submit the same data (plus other user input) back to the same controller. Is there any simple way to do this ...

How do I pass model values as javascript function parameters from inside an asp.net mvc Html helper such a Html.Radio?

Okay, pretty simple question. I think I need to drop in some escape characters, but I'm not quite sure where. Here is the javascript function I'm attempting to call: function setData(associateValue, reviewDateValue) { var associate = document.getElementById("Associate"); var reviewDate = document.getElementById("ReviewDate"); ...

Alternatives to model binding for data submission

I have an ASP.NET MVC2 application that contains a partial view that allows the user to set a variety of properties on a collection of objects. These are currently done using HTML input controls such as the textbox and dropdown list. I am using using out-of-the-box model binding to submit the user-entered values to the server via a form ...

How to show errors on in the view from a fluentvalidation result in a asp.net mvc 2 app?

Hello. I am learning asp.net mvc 2 and fluent validation. My setup is shown after the text here. My problem is i do not know how to set the errors contained in the res object on the view page in a nice way. How should this be done? As it is now no errors are displayed on the view, but the validation is working quite well. I suspect i hav...

Strange bug? when using ViewModels with MVC 2

I have run into a strange, I assume, bug when working with ViewModels and exceptions. On a view that uses a standard model with nothing but primitive types I will do something like this in the controller if there is an exception: ModelState.AddModelError("AdminError", ex); Then on my view I have something like this: <%= Html.Valid...

How to use DataType.Custom in ASP.NET MVC 2?

Can anyone tell me how to use DataType.Custom in ASP.NET MVC 2? ...

MVC.net exposing viewmodel static list to controller

I have a basic viewmodel list in VB: Transaction Status (Blackbox) Public Property TStatus() As IEnumerable(Of SelectListItem) Get Return t_status End Get Set(ByVal value As IEnumerable(Of SelectListItem)) t_status = value End Set End Property Public Sub New() ...

moving to page section through URL

I am trying: <%= Html.ActionLink("Link Label", "Index", "controller_name", new { area = "AreaName" }, new { @id = "documentation" })%> To create the appropriate html to send the user to the "documentation" part of the web page by rendering the id into the title (i.e. ) and then dropping the "#documentation" onto the end of the url lik...

Help with creating strongly typed html helper extension in Asp.net MVC 2

Hey I'm trying to create a strongly type html helper extension for a date picker using jquery ui datepicker. I have created an extension that isn't strongly typed, which works but now I'm trying to create it strongly typed. Here is what I have: public static MvcHtmlString DatePicker(this HtmlHelper html, string name, object date) ...

asp.net mvc 2 - Model Binding and Select Lists

I have the following select list: <select d="Owner_Id" name="Owner.Id"> <option value="">[Select Owner]</option> <option value="1">Owner 1</option> <option value="2">Owner 2</option> <option value="3">Owner 3</option> </select> It gets bound to: public class Part { // ...other part properties... public Owner O...

listbox containing checkboxes

Hi all, I'm using asp.net mvc-2 and would like to know if there's a way to create a listbox with a checkboxlist inside of it? ...

Simple DropDownListFor in MVC2?

I've got a table that stores a True/False value as a sqlserver bit field (Featured). First, is there a better way to generate a dropdown list for this other than manually? Second, here's what I've got so far which works but does not add selected="selected" to any items in the DDL. Edit 1: I've updated this example according to the ans...

Where should ViewModels be located?

/Controllers/ViewModels? /Views/ViewModels? Other? ...

Patterns for handling a "review input" page with DropDown items in ASP.NET MVC 2

Does anyone have suggestions for best practices using "review" pages and dropdown items? (What I mean by "review" page is, they enter data and press submit, that goes to a "pass-through" action that renders a summary of what they entered and if they like it, they press submit and it posts to an action that takes it and stuff it.) For ...

How to detect a redirect to login when using AJAX with ASP.NET MVC 2.

Hi Is there a way of detecting when an AJAX request (using jQuery) to an ASP.NET MVC application redirects me to the login page? I'm getting partial views rendered using an ajax call, but when the user has been signed out (for whatever reason), instead of returning a 302 or some other indication (that I can see) I get the login form re...

How can I read an xml file from the users computer on an ASP.NET MVC2 site?

I am writing a website to consolidate a bunch of XML files with data into one MySQL database. I need to have a way to allow users to select a directory on their computer that contains a bunch of xml files. The site then reads each of those files and takes care of consolidating the information. Is there a simple way (like the default ope...

Getting a xml error on live site but not local host.

Hi I have some XML Serialization and it works on my local machine but when I put it up on my hosting company and try it out it fails. I don't know why Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Plea...