asp.net-mvc-2

How to use ModelState.IsValid with complex objects?

I'm using NHibernate and I've got a Campaign class and it has a Client class as one of its members and I'm attempting to use ModelState.IsValid in my [HttpPost] public Create (CreateCampaignViewModel vm) method. As my ViewModel contains the object Campaign ModelStats.IsValid is always false as I'm passing the Client.Id from the form ins...

ASP.NET MVC 2: Use [Data Annotations] to reference methods that could feed DDL lists?

A generally accepted way to pass all data to a view is to have a single data model with references to both your domain model and additional data for things like drop down lists (DDL). However, partial views (view templates too) receive only a portion of the main model, not able to access the root of the Model sent to the original view. ...

Model Validation with dictionary

Hi, Say I have a model like so: public class MyViewModel { //some properties public string MyString {get;set;} public Dictionary<string,string> CustomProperties {get;set;} } And I am presenting the dictionary property like this: <%= Html.EditorFor(m => m.CustomProperties["someproperty"]) %> All is working well, however I hav...

How to make JQuery TreeView nodes into links?

Hi all, I've just created a navigation tree for a help page using ASP.NET MVC and JQuery TreeView. I can't figure out how to add links to the child nodes. What I want to do is add a property to my model (string linkText) so I can set it in each child node and turn them into links. Inserting an a tag between li tags needs to be done in...

WMD Markdown appears broken in IE8

I've already found this question on SO (which is exactly the same problem I'm having), but the OP's solution a) doesn't work for me, and b) isn't feasable in my site. On the Google Code project for WMD, it says IE8 support is on its way. My question is, does anyone know how to make WMD Markdown work in IE8 right now? Or does anyo...

Introducing MVC into ASP.Net - 404 error

I have an existing ASP.Net Application, into which I am attempting to introduce MVC2. Hopefully I can remember the steps, but what I did was the following: Created a dummy MVC2 project. Compared and merged .csproj, resulting in the Add Item commands showing MVC2 items. Compared and merged the web.config Compared and merged the global....

HTTP Host header as route value

I am trying to serve multiple virtual hosts from the same code base. One thought I had was pass the HTTP Host header as a route value because I did't want to rely on HttpContext in the controllers because of unit testability. I had planned on exposing this route value in a controller base class or something like that. I tried passing ...

Only Perform Action Once in jQuery

I am using jQuery UI and trying to disable all text boxes in a data group, but only do so once per loading of the tabs. Here is what I have so far: $(function () { $("#tabs").tabs({ cache: true, load: function (event, ui) { $(".data-group").one('load', function () { $(...

ASP.NET MVC controllers in separate assembies and Castle Windsor

I need to find a way to put my MVC controllers into a different project from the MVC project. I think I'm close. I've setup the Castle Windsor IoC container, and have my controllers in a different project. I think it's hanging up on the Web.Config. Is there a component I need to add? Here is the current exception I'm getting: No com...

Asp.net mvc 2 validate user control

Hi, I am developing a site that needs to have a small form repeated in a lot of pages. So I decided to create a user control (partial view) that has this form. This form posts to an action, so I have: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SampleProject.DoSomethingActionVM>" %> <%= using(Html.BeginForm("DoSo...

Resource not found in asp.net mvc AsyncController

Hi, I just converted a my controller to asyncController in asp.net mvc 2. (ie: spliting action method About into AboutAsync and AboutCompleted). However, I am getting a resource not found error. My route table has not change and the only reason I can think of is because I am mvcextension project. Since it does it's own wiring of c...

How would you implement a form submission templating system

hello, I need to implement a form tamplate system. The form needs to be very dynamic. It will need: Multiple textboxes Multiple dropdown menus Multiple Number fields Multiple Date fields Single Image field Single Submit button Any or all of these fields can be blank but must follow the field type. Therefore letters cannot go in numbe...

Adding data to database using MVC - with FK relationships.

Hi- I have a database and I am using the Entity Framework with Linq 2 Enities. I am working with ASP.NET MVC 2. I have a database with two tables as shown bellow: Classifieds Catergories ID(PK) CatID(PK) CatID(FK) CatName Desc ... Obviously when the user adds a new classified and when they c...

ASP.NET MVC 2 - .ascx render differences between html.RenderPartial and <%@ register

Ok, I have a master page which I include an ascx... <%@ register tagname="header" tagprefix="vb" src="~/Views/Controls/Header/Header.ascx" %> <vb:header id="pageHeader" runat="server" /> The ascx has a site map which uses the MvcSiteMapProvider... <asp:SiteMapDataSource id="SiteMapDataSource1" sitemapprovider="Secure" showstartingno...

should I always use <%: instead of <%=

I know that <%: does the html.encode thing, but there are lots of situations when I'm sure that I don't need to encode, so why should I waste time on encoding stuff that I'm 100% sure it doesn't require to be encoded like for example <%:Url.Action("Index") %> or <%: Model.Id %> (is of type int)? ...

Getting nested data out of JSON in C#

Hi, I have some JSON with Two objects and these each have 3 objects nested. { "FirstPerson": { "number": "101", "a10": "1001", "a20": "1002" }, "SecondPerson": { "number": "102", "a10": "2001", "a20": "2001" } } In c# asp.net mvc2 I've been able to get to "FirstPerson" ...

Where to store editable configuration parameters

Hi, I am building a small cms system in MVC.NET, and I have some editable variables to store. Footer information, website title etc. These are Global variables so they should only be declared once. These should be editable in the cms. Where could I store them ? Isn't it a bit stupid to create a table for them, there they only would occ...

mvc application design tips

background: i came on board to a team/ project that have developed a .net home grown mvc type architecture with home grown Ajax calls to persist data in a series of 6 screens to a context object on the server to maintain state. question 1: this seems like using mvc just to say we use mvc and not the mvc way of doing things. it feels t...

MVC.NET in VB - Select List to Html.Dropdownlist

Seems most of the examples I find are c#, so in some cases I'm left scratching my head... to make a long story short, I'm simply trying to output the selectList of items to a drop-down within my view: My ViewModel: Imports System.Web Imports Whitebox.UI Namespace ViewModels Public Class TFS_VModel Public Property AccType() As IEn...

Is a Strongly Typed Html.Telerik().DatePicker() possible in ASP.NET MVC in a Html.BeginForm()?

I have a section of a view that I would like to submit to an action so it is setup inside a Html.BeginForm() I am trying to also make use of the Html.Telerik().DatePicker() control and would like it also to strongly type linked inside the form, same as the DropDownListFor, is this possible? <% using (Html.BeginForm("MyAction", "Respond...