asp.net-mvc-2

Html.DropDownList AutoMapper problem

I am receiving this error: The ViewData item that has the key 'DepartmentId' is of type 'System.Int32' but must be of type 'IEnumerable'. with the following set up. I am not sure how to resolve it. The error is happening in the Model View code. This line: public void MapTo(Person domainModel). I am using AutoMapper to map ViewM...

Error creating compact sql database file from model

While creating compact sql database file from a model(edmx) showing following error- There is no store type corresponding to the EDM type '{0}' of primitive type '{1}'. I can't quiet get the error. Please help.......... ...

Binding arrays with missing elements in asp.net mvc

Hi, I am trying to bind a dynamic array of elements to a view model where there might be missing indexes in the html e.g. with the view model class FooViewModel { public List<BarViewModel> Bars { get; set; } } class BarViewModel { public string Something { get; set; } } and the html <input type="text" name="Bars[1].Someth...

My text isnt html?

I am using ckeditor to save my texts... (asp.net mvc) In the database the text are stored like this: <ul><li>List item</li><li>List item</li><li>List item</li></ul> And when I am running my website I want it look like this: List item List item List item But the text are the same as in the database: <ul><li>List item</li><li>List...

Please help me understand polymorphism when using generics in c#.

I am having a problem understanding how polymorphism works when using generics. As an example, I have defined the following program: public interface IMyInterface { void MyMethod(); } public class MyClass : IMyInterface { public void MyMethod() { } } public class MyContainer<T> where T : IMyInterface { public IList...

Customizing the text that renders with the LabelFor() helper method.

How can I customize the text that is rendered with the LabelFor() method? I have a bool field called IsMarried in my model, it currently renders IsMarried on the View. How can I have it say something like: "Married". <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TeacherEv...

MVC2: DateTime -> Textbox (jquery!) -> EditorFor (DateTime.ascx) -> add javascript event. How?

I defined this DateTime.ascx <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %> <%: Html.TextBox( string.Empty, (Model.HasValue ? Model.Value.ToString("dd.MM.yyyy") : string.Empty), new { @class = "whatever" } )%...

No "Specified argument was out of the range of valid values" with DropDownListFor.

In one of my views I want to output a textbox: Html.TextBoxFor(x=>x.Foo[0].Bar) %> This gives me the error "Specified argument was out of the range of valid values" if Model.Foo is empty. I have tried this with same model but with a drop down list instead: Html.DropDownListFor(x=>x.Foo[0].Bar, Model.BarList) %> No error... This i...

Asp.net MVC 2 Localization Problem in dev

I work on a multi culture web project. I use Localize and Global Ressources(resx) as multilang technology. I work in team with 2 developer. How can we share .resx . When my teammate give me the 2 Files ( myfile.resx and myfile.Designer.cs) and I include it in my project, there is no way i can add some new string in the file. The new str...

ASP.NET MVC2 UpdateModel not updating a public property included in whitelist

I have a class Foo with a field UpdateMe of type Confirmation as described below.. public class Foo { public Confirmation UpdateMe{get;set;} public int BarInt{get;set} } public enum Confirmation { N = 0, Y = 1 } I have a whitelist that has UpdateMe, and runs the following way... [AcceptVerbs(HttpVerbs.Post), ValidateAntiForg...

How to implement Tenant View Filter security pattern in a shared database using ASP.NET MVC2 and MS SQL Server

I am starting to build a SaaS line of business application in ASP.NET MVC2 but before I start I want to establish good architecture foundation. I am going towards a shared database and shared schema approach because the data architecture and business logic will be quite simple and efficiency along with cost effectiveness are key issues....

What does mean ":" in <%: and what is the difference to <%= ?

Hi In ASP.NET MVC 2 <%: tag was introduced to replace <%= for Html helpers. But what does it mean and what is the difference to the previous one? When shall I use <%= and when <%:? Thank you ...

Preventing a model binder from returning a list of null objects in ASP.NET MVC

I have a pretty complex object with numerous datatypes. A few datatypes are Lists (LazyLists to be exact). In my form, I let the user enter up to, say 3 items for this list and my form input names correspond appropriately: myObj[0].Name myObj[0].Email ...consectuviely... myObj[2].Name myObj[2].Email If the user decides to only enter...

Entity Framework 4 CTP 4 Code First: how to work with unconventional primary and foreign key names

Is there a way in Entity Framework 4 (using CTP4 and Code First if that matters) to change the conventions used to automatically identify primary and foreign keys? I'm trying to use EF with a legacy database that uses a "pk/fk" prefix rather than an "id" suffix to mark keys. Also, it's not uncommon to have multiple foreign keys to an A...

File upload in ASP.NET MVC without input field type file?

I want to have file upload possibilites on my MVC site, and I have that no problem with the input field type="file". But the problem is, the browser decides how this field should look, and that ruins the look and feel of the page. So my question is, if I want to have icons/images for download and upload and so on instead of the default ...

How can I validate a complex model using ASP.NET MVC 2

Hi have this model public class UserModel { [Required(ErrorMessage = "Le nom est requis.")] [UIHint("String")] [DataType(DataType.Text)] [DisplayName("Nom")] public string Lastname { get; set; } [DataType(DataType.Text)] [UIHint("String")] [DisplayName("Prénom")] p...

How to keep data in memory in asp.net MVC2 web app?

I have a MVC2 web app without a database that is being hosted by IIS7. The model is a custom index of some properties of a filesystem, and right now the index is stored in memory. The problem is that on a regular basis, the data stored in memory gets released, and the index must be recreated. Maybe the best solution would be to serialize...

Registering more than one VirtualPathProvider

When more than one VirtualPathProvider is registered in the hosting environment, in what order they would be called? ...

request.form issue

is there a way I can get values out of "Request.Form["person"] so I can set some of the values to an Entity? ...

how do i pass value to controller

I have a drop down where I want to pass the selected value I selected to the controller. How do I accomplish this? ...