asp.net-mvc-2

Asp.net mvc 2 .net 4.0 error when View model type is Tuple with more than 4 items

北战南征 提交于 2019-12-07 14:16:23
问题 When I create strongly typed View in Asp.net mvc 2, .net 4.0 with model type Tuple I get error when Tuple have more than 4 items example 1: type of view is Tuple<string, string, string, string> (4-tuple) and everything works fine view: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebUI.Master" Inherits="System.Web.Mvc.ViewPage<Tuple<string, string, string, string>>" %> controller: var tuple = Tuple.Create("a", "b", "c", "d"); return View(tuple); example 2: type of view is

ASP.NET MVC2 LINQ - Repository pattern, where should the pagination code go?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 12:42:06
问题 I'm working on adding an HtmlHelper for pagination, but I am unsure where the proper and/or most beneficial place to put certain parts of the pagination code from a performance and maintainability standpoint. I am unsure if the Skip(), Take() and Count() portions of Linq to SQL data manipulation should live within the repository or the controller. I am also unsure if their order and where they are used affects performance in any way. If they live within the repository from my understanding

How to Load Partial Views with Jquery UI Tab by passing parameters?

佐手、 提交于 2019-12-07 12:25:44
问题 I have a parent page ( DistributionReview.aspx ) that has a Deposit Date to select using DatePicker. Just below I have two tabs (* DistributionByType * and DistibutionByStatus ) that I want to load PartialViews. Here the parameter to the PartialView is DepositDate . And I have a custom ViewModel called DistributionReviewModel that the parent page is implementing. I am coming across articles that are directly loading static partial views(Ex: http://www.kevgriffin.com/blog/index.php/2010/02/23

How to provide ASP.NET MVC2 master pages with a model indepdent of the controller

孤者浪人 提交于 2019-12-07 12:02:54
问题 I'm using strongly typed views and autofac for Dependency Injection under ASP.NET MVC2 and I'm trying to get a common dynamic header via dependency injection. I.e. i want this to happen without the view having to be away of this content even existing and i was hoping to avoid static discovery of the container and manual resolution, but I can't find a way to easily inject the master or a partial view included in the master via either ctor or property injection. I can't imagine this is an

Optimizing C# code in MVC controller

旧巷老猫 提交于 2019-12-07 11:42:25
I am making a number of distinct controllers, one relating to each stored procedure in a database. These are only used to read data and making them available in JSON format for javascripts. My code so far looks like this, and I'm wondering if I have missed any opportunities to re-use code, maybe make some help classes. I have way too little experience doing OOP, so any help and suggestions here would be really appreciated. Here is my generalized code so far (tested and works); using System; using System.Configuration; using System.Web.Mvc; using System.Data; using System.Text; using System

Ajax long polling not working correctly

孤人 提交于 2019-12-07 11:02:24
问题 I am developing a simple strangers chat application using long polling in MVC 2. Its works fine in my development machine if i am opening the application different browsers.. i mean if i loaded the application in IE and mozilla, it works fine if i took the appliction in two tabs of a browser (eg:IE) , the long polling are not firing from both tabs.. I mean, there is a start button to start chat which fire long polling. I can see it calling actions while debugging.. And my problem is, When i

PathTooLongException after migrating from ASP.NET MVC 1 to ASP.NET MVC 2

走远了吗. 提交于 2019-12-07 10:45:08
问题 I had updated my app from MVC 1 to MVC 2. After that some pages throws PathTooLongException : [PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.] System.IO.Path.SafeSetStackPointerValue(Char* buffer, Int32 index, Char value) +7493057 System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) +387 System.IO.Path.NormalizePath(String path,

How to use a ShortDate string format with Html.TextBoxFor

我怕爱的太早我们不能终老 提交于 2019-12-07 09:05:41
问题 Using Entity Framework with MVC2, I have a series of date textboxes, that I want to display data from the model in a short date format, but I have to use Html.TextBoxFor in order for the update code to work (Having tried using HTML.Textbox the data never gets saved to the model). <%: Html.TextBoxFor(model => model.Item.Date, String.Format("{0:d}", Model.Item.Date))%> I've tried manipulating the string format expression, and have added metadata to a partial class mapped to the Entity Framework

MVC Dataannotation validation rule for a collection?

拈花ヽ惹草 提交于 2019-12-07 08:13:53
问题 Is there a dataannotation validate rule for a collection based property? I have the following <DisplayName("Category")> <Range(1, Integer.MaxValue, ErrorMessage:="Please select a category")> Property CategoryId As Integer <DisplayName("Technical Services")> Property TechnicalServices As List(Of Integer) I'm looking for a validator that i can add to the TechnicalServices property to set a minimum for the collection size. 回答1: I think something like this might help: public class

Upgrade MVC 2 to MVC 3 issues with views

落花浮王杯 提交于 2019-12-07 08:12:09
问题 I'm attempting to upgrade my existing ASP.net MVC 2 web application to MVC 3 so I can use the goodness that is the Razor Viewengine and other said improvements. After using the converter to convert my app from mvc2 to mvc3 I'm having issues with my strongly typed views. As an example here we have a view user control that is strongly typed to the class Profile <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Profile>" %> During compilation I'm getting Compiler Error Message: