asp.net-mvc-2

RedirectToAction is not redirecting

左心房为你撑大大i 提交于 2019-12-20 04:16:06
问题 Shouldn't this work? If I had a break point on the last } it stops there but it never gets to the Contact Action, and the page after being posted it's just a blank page with no source code what am I missing ? Thank you. 回答1: Your Contact(ContactModel model) should not be "void", instead it should be public ActionResult Contact(ContactModel model) { //.... some code return RedirectToAction("Contact"); } 来源: https://stackoverflow.com/questions/4137775/redirecttoaction-is-not-redirecting

C# MVC2 Jqgrid - what is the correct way to do server side paging?

人走茶凉 提交于 2019-12-20 04:15:07
问题 I have a jqgrid where the database table has a few thousand rows, but the jqrid shows only 15 at a time. It should be displaying very quickly (it doesnt take long to query 15 rows). But instead it takes 10 - 20 seconds, which indicates to that it is retrieving the entire table each time. The grid is defined like this: $("#Products").jqGrid({ url: url, mtype: "get", datatype: "json", jsonReader: { root: "Rows", page: "Page", total: "Total", records: "Records", repeatitems: false, userdata:

Does the DataAnnotations.DisplayAttribute.Order property not work with ASP.NET MVC 2?

给你一囗甜甜゛ 提交于 2019-12-20 03:15:18
问题 I set values for the Order property of the Display attribute in my model metadata. [MetadataType(typeof(OccasionMetadata))] public partial class Occasion { private class OccasionMetadata { [ScaffoldColumn(false)] public object Id { get; set; } [Required] [Display(Name = "Title", Order = 0)] public object Designation { get; set; } [Required] [DataType(DataType.MultilineText)] [Display(Order = 3)] public object Summary { get; set; } [Required] [DataType(DataType.DateTime)] [Display(Order = 1)]

What is the best way to add attributes to auto-generated entities (using VS2010 and EF4)

删除回忆录丶 提交于 2019-12-20 01:59:13
问题 ASP.NET MVC2 has strong support for using attributes on entities (validation, and extending Html helper class and more). If I generated my Model from the Database using VS2010 EF4 Entity Data Model (edmx and it's cs class), And I want to add attributes on some of the entities. what would be the best practice ? how should I cope with updating the model (adding more fields / tables to the database and merging them into the edmx) - will it keep my attributes or generate a new cs file erasing

Integrate Markitup text editor to ASP.NET MVC project

末鹿安然 提交于 2019-12-19 19:42:32
问题 I'm trying to add markitup text editor with markdownsharp http://markitup.jaysalvat.com/home/ to my MVC ASP project and kindof confused how to go about it. I added a class from markdownsharp and tested the function. that is working fine but confused how to embed the editor in my view. Using Visual Studia 2010. Please guide regarding the same. 回答1: The documentation contains many examples. 回答2: @user488652: As MarkItUp uses jQuery to transform a DIV into a complex editor, I am having similar

Why can't I set a breakpoint in a ASP.NET view?

馋奶兔 提交于 2019-12-19 19:12:31
问题 If I set a breakpoint in the compiled code (for instance in an action), I can then step through, and eventually am stepping through the generation of the View. I've found this useful a couple of times, but it's tedious as you have to step through a lot of code to get there. However, I can't set a breakpoint in view. I just receive the message 'This is not a valid location for a breakpoint' from VS2008. Why is this? 回答1: Right click on the code you want to break on and go to "Breakpoint ->

ASP.NET MVC “The call is ambiguous” Error (System.IO.TextWriter.Write)

若如初见. 提交于 2019-12-19 12:49:11
问题 I am creating a dynamic CSS file in ASP.NET MVC2, and I'm now encountering an exception. Everything was working fine, but all of a sudden I'm getting this error message for 2 variables: The call is ambiguous between the following methods or properties: 'System.IO.TextWriter.Write(string, params object[])' and 'System.IO.TextWriter.Write(char[])' An example of the code is: #pageMaster .CCResultsText2 { font-size: <%= ViewData.Model.FontSize %>; color: <%= ViewData.Model.FontColor %>; } This

The view '~/Views/Login/Login.aspx' must derive from ViewPage, ViewPage<TModel>, ViewUserControl or ViewUserControl<TModel>

早过忘川 提交于 2019-12-19 11:47:46
问题 So I am getting this error on ASP.NET mvc2 solutions that used to work fine. I had to install Visual Studio 2012 and was running low on disk space, so had to manually uninstall some Visual Studio 2010 functionalities which didn't seem to be completely necessary at the moment. Now whenever I try to debug an application which targets the 4.0 .NET framework I get this error. I tried re-installing Visual Studio and the .net framework, but it keeps kappening. I don't know what to do. Also, i tried

Problems trying to attach a new EF4 entity to ObjectContext while its entity collection entities are already attached

寵の児 提交于 2019-12-19 11:47:14
问题 This is somewhat complicated to explain, so please bear with me. I have an ASP.NET MVC 2 project that is slowly killing me in which I'm trying to take form data and translate it into entities to create or update, depending on the context of the situation. The most relevant parts (pseudo-code): Entity Game Scalar properties EntityCollection<Platform> Platforms And the basic workflow is: Form data -> model bound to a DTO -> mapping the DTO to an EF4 entity with AutoMapper. It all works well

Multiple file upload using Request.Files[“files”] MVC

早过忘川 提交于 2019-12-19 10:50:16
问题 This is my Code. I want to uplade 3 file into my database first in View I write this : <% using (Html.BeginForm(Actionname, Controller, FormMethod.Post, new {enctype="multipart/form-data"})){%> ..... .... and this is 3 file uplaoding: <input type="file" name="files" id="FileUpload1" /> <input type="file" name="files" id="FileUpload2" /> <input type="file" name="files" id="FileUpload3" /> In controller I use this code: IEnumerable<HttpPostedFileBase> files = Request.Files["files"] as