asp.net-mvc-2

Some fields are binding on postback some don't

I have a view containing a number of fields <div class="editor-label"> <label for="Supplier">Supplier</label> </div> <div class="editor-field"> <input id="Supplier" name="Supplier" type="text" value="Swifts Antiference Division Ltd" /> <input id="SupplierId" name="SupplierId" type="hidden" value="1" /> </div> <div cla...

Passing data from the model into custom validation class

I have a data validation class that checks whether the start date of a meeting is before the end date. The model automatically passes in the date that requires validation, but i'm having a bit of difficulty passing the data that it needs to be validated against. Here's my validation class sealed public class StartLessThanEndAttribute ...

ASP.NET MVC Form Values not being set on Post

Hi All, I have a model object called Problem: [Table(Name = "Problems")] public class Problem { [HiddenInput(DisplayValue = false)] [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)] public int ProblemId { get; set; } [Display(ResourceType = typeof(Resources.Resources), Name = "TablePerso...

Overridding ComponentModel attributes (ie, DisplayName) doesn't work as expected

I have two classes: public class DocumentViewModel { public virtual string DocumentNumber { get; set; } } public class PurchaseOrderViewModel : DocumentViewModel { [DisplayName("PO Number")] public override string DocumentNumber { get; set; } } And a view: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserContro...

Installing ASP.Net MVC 2 project templates without the exe

Can anyone suggest a way to get the MVC templates installed without running the MVC exe. I'm trying to get ASP.Net MVC 2 up and running, and I still don't have admin access to my PC (new job!) which you need to run the MVC installer. I know you don't need the templates but I'm only beginning MVC so fine the templates really useful. I'...

Learning Web Development starting with ASP.NET MVC

Hi, I have been working with C# for past four years at the enterprise level. Now, I have taken a decision of moving to Web side of the things. Since I am well versed with C# and WCF I naturally zeroed in on ASP.NET as I need not learn a new Programming language. Learning just the Web Framework will suffice. I have read a lot regarding ...

How to parse a string URL into MVC Route Values (area, controller, action, querystring)?

Is there a method to extract the area, controller, action, and querystring from a URL in ASP.NET MVC? Don't want to reinvent the wheel implementing my own if there's already a way to do it. Thanks! ...

How to add route for and handle domain.com/?latest

I'm trying to handle the following url's: (1) domain.com, (2) domain.com/?latest This is what I think should be it... Global.asax routes.MapRoute( "HomeIndex", // Route name "/?{sortBy}", // URL with parameters new { controller = "Home", action = "Index", sortBy = UrlParemeter.Optional } // Parameter defaults ); HomeCont...

ASP.NET MVC data annotations client side validation with inherited RegularExpressionAttribute

To keep my model validation clean I would like to implement my own validation attributes, like PhoneNumberAttribute and EmailAttribute. Some of these can favorably be be implemented as simple classes that inherit from RegularExpressionAttribute. However, I noticed that doing this breaks client side validation of these attributes. I am a...

NHaml T4 templates for CRUD?

Hello, I want to ask if anyone have or seen T4 templates for NHaml that are same as default T4 CRUD (List, Create etc) templates from MVC 2.0? Thanks for any source :) ...

MVC2: Validation (Data Annotations) with two field dependency.

Example: We have a conditional field. This conditional field is a radio button with the following two values “yes” and “no”. Lets say the name of this radiobutton is “AAA”. This conditional field “AAA” should only be displayed when another radio button field “BBB” is set to “yes”. (Values of radio button “BBB” are also “yes” and no”) ...

How do I configure ASP.NET MVC routing to hide the controller name on a "home" page?

Following on from this question: ASP.NET MVC Routing with Default Controller I have a similar requirement where my end user doesn't want to see the controller name in the url for the landing or "home page" for their application. I have a controller called DeviceController which I want to be the "home page" controller. This control...

ASP.NET MVC: DropDownList validation

Note: The following is just an example. I'm pretty new to ASP.NET MVC and I'm trying to get my head around how validation of dropdown lists work. I have the following property in my ProfileViewModel class: [DisplayName("Gender")] public bool? Gender { get; set; } null is meant to mean "unknown", true female and false male. In the vie...

HttpHandler Property Injection using Ninject returning null

I have the following httphandler: public class NewHandler : IHttpHandler { [Inject] public IFile FileReader { get; set; } public NewHandler() { } public void ProcessRequest(System.Web.HttpContext context) { .... var something = SomeMethod(FileReader); .... ...

Need to Save HTML markup from a form element

I want to save html markup in my database for a field from an ASP.Net MVC2 application. Upon reading I found that using the [ValidateInput(false)] attribute lets you do that. But it is not working for me. The data comes from the extjs htmleditor form element. Anyone has any ideas? Is there something else I need to do? Any setting in w...

ASP net MVC ActionLink

How can I produce following code in AspNet MVC with ActionLink (not format throw css) <a href="#"><anotherHtmlElement>Title</anotherHtmlElement></a> example <a href="#"><strong>Title</strong></a> Sorry for my bad english ...

Mysql storing webs ite admin permissions

I have a project using C# and MySQL. I need to store permissions for a admin portal setting. There is currently 6 main permissions( read, write, view, update create...) but each of these permissions can be applied to n entities. so a user can have create, read to site a, d , f but have no permissions to the other 100+ sites. I thought of...

Ninject 2.0: Passing different parameters depending on implementation

Hi everybody, I have just started to work with Ninject 2.0 with ASP.NET MVC 2. So, I have an interface IMongoRepository and class MongoRepository. MongoRepository receives a parameter string collection. Depending on the collection I want to use, I pass in a different value in parameter for MongoRepository. I hope I am phrasing this co...

MVC View html ouput in json

Probably this has been asked so many times before but i can't find answer any where. I have a Action public ActionResult SearchResult() { return View(); } Now i need some data as well which is related to View, so i am trying to do following public JsonResult SearchResult() { var result = new JsonResult(); result.Data = new...

ASP.NET MVC Html.TextBoxFor rendered different value than <%: Model.value %>

This is very strange and I don't know why. I have a ViewModel that return some value for my object, when rendering it, they have different values, yet, they points to the same property: <%: Model.myProperty %> That returns "25", which is what I've set the property to be. But when rendered it as an textbox, it returned "0" as the value...