asp.net-mvc-2

Extending ASP.NET MVC 2 Model Binder to work for 0, 1 booleans

柔情痞子 提交于 2019-11-29 04:07:06
I've noticed with ASP.NET MVC 2 that the model binder will not recognize "1" and "0" as true and false respectively. Is it possible to extend the model binder globally to recognize these and turn them into the appropriate boolean values? Thanks! Something among the lines should do the job: public class BBinder : DefaultModelBinder { public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); if (value != null) { if (value.AttemptedValue == "1") { return true; } else if

Visual Studio 2010 Local SSRS Report (.rdlc) with Object Data Source

徘徊边缘 提交于 2019-11-29 03:06:19
I've created more projects using ReportViewer 2005 and 2008 in local processing mode than I can count on my hands. All Visual Studio 2005 or 2008 ASP.NET web forms projects. I always used some flavor of Object data source for the reports. Tonight, I attempted to add the same functionality to a Visual Studio 2010 MVC 2 project and am failing miserably. First, the Add New Item > Reporting > Report is now a 2008 RDLC and not a 2005 RDLC report. Secondly, when trying to add a DataSet, my usual method of create a data proxy class with static methods that return IEnumerables(Of Stuff) will not show

Can EditorFor() be used to create <input type=“file”>?

谁说胖子不能爱 提交于 2019-11-29 02:59:12
Given this model, is it possible to use the Html.EditorFor() to render a file upload input element to the page? I played around with the Datatype of the property FileName, and it was definitely impacting the editor form rendered. public class DR405Model { [DataType(DataType.Text)] public String TaxPayerId { get; set; } [DataType(DataType.Text)] public String ReturnYear { get; set; } public String FileName { get; set; } } Strongly Typed *.aspx page looks like this <div class="editor-field"> <%: Html.EditorFor(model => model.FileName) %> <%: Html.ValidationMessageFor(model => model.FileName) %>

Is asp.net MVC2 included in .net 4.0 framework?

删除回忆录丶 提交于 2019-11-29 02:51:06
I've installed .net 4 in the server. Now I don't know if I must install the MVC 2 for VS2008 or what because I got this error: Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Levi VS 2010 comes with MVC 2, but it's not a part of the .NET Framework proper. This means that if you go download the .NET Framework 4 redistributable, it will not include the MVC 2 runtime. But since MVC is bin-deployable, this is fine. Your application - when deployed to a .NET 3.5

ASP.Net MVC2 Custom Templates Loading via Ajax and Model Updating

杀马特。学长 韩版系。学妹 提交于 2019-11-29 02:43:52
I have a view model with a collection of other objects in it. public ParentViewModel { public int Id { get; set; } public string Name { get; set; } public List<ChildViewModel> Child { get; set; } } public ChildViewModel { public int Id { get; set; } public string FirstName { get; set; } } In one of my views I pass in a ParentViewModel as the model, and then use <%: Html.EditorFor(x => x) %> Which display a form for the Id and Name properties. When the user clicks a button I call an action via Ajax to load in a partial view which takes a collection of Child: <%@ Control Language="C#" Inherits=

Can I get the controller from the HttpContext?

╄→гoц情女王★ 提交于 2019-11-29 02:06:42
问题 Given an HttpContext (or HttpContextBase), is there a way to get an instance of the Controller? 回答1: The HttpContext will hold a reference to the MvcHandler , which will hold a reference to the RouteData , which will hold a reference to what controller is being invoked by a particular route. NB: This doesn't give you the actual controller, only the controller that the specific route is going to catch. GetController(HttpContextBase httpContext) { var routeData = ((MvcHandler)httpContext

Extract Display name and description Attribute from within a HTML helper

寵の児 提交于 2019-11-29 01:41:56
问题 I am building a custom HTML.LabelFor helper that looks like this : public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> self, Expression<Func<TModel, TValue>> expression, Boolean showToolTip) { var metadata = ModelMetadata.FromLambdaExpression(expression, self.ViewData); ... } To be able to get the proper name for the property I am using the following code : metadata.DisplayName And on the property of the ModelView class I got : [DisplayName("Titel")] The problem is

JQuery DataTables .Net Server Side Pagination Issues

百般思念 提交于 2019-11-29 01:20:58
I'm working on a bug fix right now for an application at work where the prior developer (since gone) didn't bother to paginate the data results on a page meant specifically for listing out data results. This of course has reared it's ugly head as users are starting to see long running script errors in IE. This, combined with the sheer data volume size, is making web pages nearly useless. Fast forward to my attempts to fix it and they've gone pretty well. The site is a .NET MVC 2 site that was developed using DataTables to add search/sort/paging functionality on the client. I'd just completed a

Deploying Asp.Net MVC 2 /C# 4.0 application on IIS 6

喜你入骨 提交于 2019-11-29 00:40:50
问题 I got a problem migrating from VS.Net 2008 / MVC 1 to VS.NET 2010 (+C# 4.0) / MVC 2 The web.config has been updated, the site runs well in Cassini, but my problem now is deploying on IIS 6. I updated the web site to run using ASP.Net 4, but whatever URL I try, I always have a 404 error. It's as if the routing was not taken into account (yes, the wildcard mapping has been done). I do not understand this mess and could not google anything interesting... Thanks for your suggestions ! 回答1: Ok I

MVC 2 - Passing enum to CheckBoxFor

拥有回忆 提交于 2019-11-29 00:09:28
Let's assume we have a model: public class Document { public string Name { get; set;} public List<DayOfWeek> WeekDays { get; set; } } Is it possible to render checkboxes that represent days of week for that model? I've searched the internet but did not find any solution. I mean it works whith CheckBoxFor(model=> model.SomeProperty) but it does not work if SomeProperty is List<DayOfWeek> . DayOfWeek here is an enumeration. Thanks in advance. You can enumerate on the values of the enum and manually create the checkboxes. Using the same name for each checkbox will submit them as an array in the