asp.net-mvc-2

Model binding when rendering a partial view multiple times (partial view used for editing)

Greeting Everyone, I'm having a little trouble with a partial view I'm using as an edit form. Aside from the hidden elements in the form, the model is null when passed to my EditContact post controller. I should add, I realize there's a more seamless way to do what I'm doing using AJAX, but I think if I can solve the clunky way first ...

Get binary from uploaded file (image) in ASP.NET MVC

I'm using the following code: <form action="" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <input type="submit" /> </form> And... [HttpPost] public ActionResult Index(HttpPostedFileBase file) { if (file.ContentLength > 0) { var fileName = P...

What to do for input sanitization?

I need to start worrying about user input. I notice the htmlhelper class doesnt do a great job of this. Can anyone suggest a nice framework for input sanitization? I'm using asp.net mvc2. ...

Is there an ASP.NET MVC 2 editor Templates library?

Hi, The custom (editor) templates in ASP.NET MVC 2 make it possible to create re-usable UI components (such as a selectlist, radio button list). Even ajax components are possible. Is there some website where developers can share their custom templates with each other? It seems a bit redudant to write these basic components by my own i...

Using a console application to host WCF endpoints that expose asp.net ProfileService, ProfileService and RoleService

Hi All, I've got an MVC web application that is used as an interface to a Console based app that exposes a bunch of ServiceHost/s using the net.pipe protocol. I would like to use the asp.net membership/role/profile provider to manage my users and their roles and profile information (Inside the Console Application). I've done this in q...

Path to EditorTemplates in ASP.NET MVC

How can I tell the viewengine to look for editortemplates in another area that is in another web project? ...

Dynamically populate a listbox from a textbox in ASP.NET MVC 2

Here's what i'm trying to do: 1 textbox with an Add button, and a ListBox underneath with a Delete button, along with a bunch of other fields. You can probably guess the functionality: type something in the text box and click Add, it will add that string into the listbox below. Select an item in the listbox and hit Delete, the item is ...

Is correct use Interfaces this way, is there a better option?

Hey guys, It's 5 am here, I was doing some code... when this came out: public interface IViewModel { } public interface IToViewModel<T> where T : IViewModel { } public static class MvcExtensions { public static T ToViewModel<T>(this IToViewModel<T> self) where T : IViewModel { var instance = Activator.CreateIns...

Custom Delete Function in jqGrid

I am trying to customize the delete function in jqGrid. I have enabled the delete button on the grid $("#myGrid").jqGrid('navGrid', '#pager', { add: true, addtitle: 'Add Customer', edit: true, edittitle: 'Edit Customer', del: true, deltitle: 'Delete Customer', refresh: true, refreshtitle: 'Refresh data', ...

Asp.net mvc RenderAction RouteData Controller and Action values

I am trying to create a RenderAction method on the Master page that will dynamically generate a side bar based on the current controller and action. When the RenderAction is called in the view it is populated with the controller and action of that particular RenderAction Method. For Example, if I am on the controller of “Home” and acti...

Using the 'Title' tag in an ActionLink in MVC2

In an article titled Inegrating jQueryUI with MVC is this code snippet: <li><%= Html.ActionLink("Home", "Index", "Home", new { title="Home Page" }, null)%></li> I think the article pre-dates MVC2 release and that might be why i get a syntax errors at the opening brace: Type or 'With' expected. thx ...

Do controller action parameters automatically map to view input tags?

I have a controller with an action that has a parameter (JobID). I was surprised to see that it automatically mapped to a hidden field with the same name in the view that the controller returned. I am using strongly typed view models and assumed I needed to pass all model properties as part of the view model. It appears that this is not ...

Session not sticking for ASP.NET MVC2 in IIS7.5 in IE8

We have an ASP.NET MVC2 web application. For reasons outside the scope of this issue we decided to use the classic session state in the application. Following features are implemented in it related to session. Session_Start event handler in global.asax stores a variable in session. This is in relation to a workaround to detect session ...

Initiate Properties automatically using StructureMap

If i have N numbers of classes on each of them i am declaring for example property which contains some app setting values from config file. public static IAppSettings AppSettings { get; set; } I want to populate this property automatically when class is created. I am thinking to achieve this goal using StructureMap. I want to "sa...

Telerik.Web.Mvc grid. In the .DetailView not calling the Ajax method.

I am using free Telerik.Web.Mvc grid and following this example: http://demos.telerik.com/aspnet-mvc/grid/hierarchyajax My Issue: I am populating the grid with search results after user input some data and submit with a search button In the DetailView() method I reference my 'SearchQuote_QuotesForHierarchyAjax' method, which is in defi...

Data Annotation and Metadata Types and "Stitching Together Values" (C#)

I'm trying to setup data annotation validation for an object in my model and it has a special need. I have to essentially take some extra properties that I'm adding and combine them to get the value of a real property. For example I have a base object: Task { public DateTime? Due } But my form has the fields of: Task.DueDate Task...

asp.net mvc: using editor templates to update a list of objects

I am banging my head against this wall for some time, some help will be highly appreciated: Let's say I we have a simple Model: public class Contact { public string FirstName { get; set; } public string LastName { get; set; } } And a simple editor temple: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Rpd...

in asp.net MVC 2 /beta Date formate proble is as :

Hi, in asp.net mvc 2 or beta , model not accepting the date 13 ( more than 12'th of date) . Model showing error ads " The value '20/10/2010' is not valid for MyDateFieldName " what have to do ? Model showing false status as ModelState=False. why ? ...

Validation failed or similar event using MicrosoftMvcValidation.js

Is there a validation failed or similar event raised by the MicrosoftMvcValidation.js framework and if so how do I go about hooking into it ? Currently I have a "global" function that displays a progressing overlay on submit of a form but when validation fails I have no way of removing this .... ...

Registering dynamic routes, needs an app restart?

Hi, I am working on a small CMS for fun and as part of this I register routes from a database at app start. It is possible for a user to add a route themselves. The problem is that this route is stored in the db and so isn't registered until app restart. Is it possible to re-register routes without an app restart? If not, how do I res...