asp.net-mvc-2

Using the same code in different (partial) views

Maybe this question is quite simple because I'm new to MVC2. I have a simple demo MVC project. (1) A weak-typed view: Index.aspx <% Html.RenderPartial("ArticalList", ViewData["AllArticals"] as List<Artical>); %> (2) A strong-typed partial view: ArticalList.ascx <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<...

asp.net mvc2 validate type double

[MetadataType(typeof(Deal_Validation))] public partial class Deal { } public class Deal_Validation { [Required] public string Title { get; set; } public double? EstValue { set; get; } } How to validate EstValue (check if it is of type double?) Thanks ...

.net Regular Expression to match any kind of letter from any language

Which regular expression can I use to match (allow) any kind of letter from any language I need to match any letter including any diacritics (e.g. á, ü, ñ, etc.) and exlude any kind of symbol (math symbols, currency signs, dingbats, box-drawing characters, etc.) and punctuation characters. I'm using asp.net MVC 2 with .net 4. I've trie...

Model binding & derived model classes

Does ASP.NET MVC offer any simple way to get model binding to work when you have model classes that inherit from others? In my scenario I have a View that is strongly typed to List<Person>. I have a couple of classes that inherit from Person, namely PersonTypeOne and PersonTypeTwo. I have three strongly typed partial views with names ...

ASP.NET MVC - hiding id in URL?

I'm building a basic blog application just now, for viewing data I'm just using the default route, i.e. - routes.MapRoute ( "Default", // Route name "{controller}/{action}/{id}", new { controller = "Blog", action = "Index", id = UrlParameter.Optional } ); So that when you go to mysite.com/View/12 it displays the blog ...

MVC2 Client validation with Annotations in View with RenderAction

I'm having problem with client side validation on a View that renders a dropdownlist with help of a Html.RenderAction. I have two controllers. SpecieController and CatchController and I've created ViewModels for my views. I want to keep it as DRY as possible and I will most probably need a DropDownList for all Specie elsewhere in the n...

How to use rich text in htmlhelpers or use html and links in asp.net mvc 2?

Hi all I wanted to allow the users to enter html and links in textbox. How can I achieve something like this in ASP.NET MVC 2? I have something like this now... <div class="editor-field"> <%= Html.TextAreaFor(model => model.Description) %> <%= Html.ValidationMessageFor(model => model.Description) %> </di...

Problem migrating membershipProvider functionality from mvc1 to mvc2

I am migrating a web app in mvc1 to mvc2. When it came down to migrating my MembershipProvider authentication I keep getting errors that MembershipProvider and MembershipCreateStatus type cannot be found. I do have the reference to System.Web which to my understanding includes the Security reference, but when I examine the the object, th...

Renaming node from jsTree inside a mvc2 form.

I've the following code: <% using (Html.BeginForm("Update", "SkillLevel", FormMethod.Post, new { id = "TheForm" })) { %> <div id="demo3" class="demo"> <ul> <li id="shtml_1"> <a href="#">Root node 1</a> <ul> <li id="shtml_2"> <a href="...

Is it possible that each areas on MVC2 run on separate IIS website?

Lets say I want my Admin (area) to run on HTTPS and the default site runs on HTTP. Is this possible? How? ...

asp.net mvc jquery - display partial page as return result?

With jQuery, is it possible to call /ControllerName/GetSomething?parameter=test, while in GetSomething method I have following: public ActionResult Details() { filterQuery.OrderBy = Request.QueryString["parameter"]; var contacts = contactRepository.FindAllContacts(filterQuery).ToList(); return View("ContactList"); } and ...

How to inject UrlHelper in MVC using Castle Windsor

I have a component that has a dependency on UrlHelper that I need to register using Castle Windsor. UrlHelper in turn has depdendencies on RequestContext (and RouteCollection). Now my controller has a Url property of type UrlHelper but cannot really access this as far as I can tell. What is the most efficient way to register my UrlHelp...

ASP.NET MVC2 Access-Control: How to do authorization dynamically?

We're currently rewriting our organizations ASP.NET MVC application which has been written twice already. (Once MVC1, once MVC2). (Thank god it wasn't production ready and too mature back then). This time, anyhow, it's going to be the real deal because we'll be implementing more and more features as time passes and the testruns with MVC...

MVC form values post to route

I'm not sure if what I am try to do is possible but here goes. I have a form with two drop down lists - category and subcategory. When a category is selected an AJAX call is made to get the list of subcategories. For demo purpose I've selected a category of 'Fruit' which shows all of the subcategories for this group. <select id="catego...

DataAnnotations Automatic Handling of int is Causing a Roadblock

Summary: DataAnnotation's automatic handling of an "int?" is making me rethink using them at all. Maybe I'm missing something and an easy fix but I can't get DataAnnotations to cooperate. I have a public property with my own custom validation attribute: [MustBeNumeric(ErrorMessage = "Must be a number")] public int? Weight { get; set; }...

How do I protect my website from javascript injection attacks when using rich text editors?

Hi all I am using the markitup editor to get the value for one of my fields and storing it a sql server 2008 db. Now I guess the problem is people having script tags and javascript in the editor and injecting malicious scripts and I have my validate input turned false. So can anyone suggest me a way to write a custom validation method th...

How should I do authentication in a ASP.Net MVC site?

I have a site which has an area that requires authentication. Right now I use the roles attribute on all the controllers in that area, and I run a query to retrieve that users ID, and all their settings. It seems like a code or design smell to me that I am retrieving the userid and settings each time a controller in that area loads up? ...

Custom route doesn't find controller action

For some reason my application isn't routing to my controller method correctly. I have a routelink like this in my webpage - <%= Html.RouteLink("View", "Blog", new { id=(item.BlogId), slug=(item.Slug) }) %> In global.asax.cs I have the following routes - routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( ...

How to safely use PayPal IPN with Asp.Net MVC

Here are two sources for PayPal IPN: Kona.Web IPN DotNetNuke IPN DNN has a loop in the beginning of the Page_Load method that captures txn_type and txn_id, which I don't see in the Kona code. DNN also captures payer email and other information into local variables. I am trying to make sure that I incorporate some of the security chec...

How can I read the properties of an object that I assign to the Session in ASP.NET MVC?

Hey all, I'm trying my hand at creating a session which stores member information which the application can use to reveal certain navigation and allow access to certain pages and member role specific functionality. I've been able to assign my MemberLoggedIn object to the session in this way: //code excerpt start... MemberLogg...