asp.net-mvc-2

ASP.net MVC2. Populated model is not getting back to the controller

[亡魂溺海] 提交于 2019-12-11 14:58:50
问题 Say I input 'email@domain.com' and 'password' into the login fields. The data annotations in AuthModel.cs throw back that the values aren't populated. So the data in the html form is never actually populating the model thats being thrown around. In my awesomeness, I made a lot of hurried changes yesterday before closing the solution and didn't test the changes I had made. As a result, I don't know what I changed to break this. If I need to post anything else let me know. AuthController.cs ...

ASP.Net MVC - Is this entity layer a step too far?

半腔热情 提交于 2019-12-11 14:55:21
问题 I have a domain data model which returns a class such as the following: public class ZombieDeath { public virtual int ZombieId {get;set;} public virtual FatalHit {get;set;} } public class FatalHit { public virtual int HitId {get;set;} public virtual string Zone {get;set;} public virtual string Weapon {get;set;} } When passing this data back to my grids, I've read that is best to always return data to the views in a flattened format. So I have the following class that represents a grid row:

Incorrect page loading in MVC

送分小仙女□ 提交于 2019-12-11 14:26:39
问题 We are currently hosting a asp.net mvc 2 website in IIS 6. In this application we override the 'Create Controler' method and configure a custom view engine. This engine specifies the location of the views depending on the url format. for example; if a user lands on www.asite.com/test/1.0/index.aspx the view engine tells mvc to look for index.aspx in the 'sitedirectory/test/1.0/views/pages/' directory; string versionDirectory = String.Format("~/{0}/{1}", offerCode, version.ToString("#0.0000"))

Limit JavaScript and CSS files on ASP.NET MVC 2 Master Page based on Model and View content

佐手、 提交于 2019-12-11 14:08:24
问题 I want to include certain .js and .css files only on pages that need them . For example, my EditorTemplate DateTime.ascx needs files anytimec.js and anytimec.css . That template is applied whenever I use either the EditorFor or EditorForModel helper methods in a view for a model with a DateTime type value. My technique: I've put this condition into the <head> section of my master page. It checks for a DateTime type property in the ModelMetadata. <% if (this.ViewData.ModelMetadata.Properties

asp.net mvc partials do they know if the are run stand alone or as part of a page

南楼画角 提交于 2019-12-11 13:51:52
问题 Does anyone know, if a partial view ( PartialViewResult ) in an ascx file - knows if it is running stand alone - called directly from the browser or as part of a page. I would like to treat these cases differently. Edit: Case 1: In the page case it could be that a page has a few partials that are loaded using ajax while the page is being built. The partials might be called again using ajax according to the users actions. In this case I consider them as controls on a page. Case 2: In the stand

ASP.NET MVC 2.0 Unused Model Property being called when posting a product to the server?

半城伤御伤魂 提交于 2019-12-11 13:51:07
问题 i have my auto-generated linq to sql classes, and i extend this class using partial classing (instead of using inheritance), and i have properties that that i've put in later which are not part of the database model and should not be. these are things like "FinalPrice" and "DisplayFinalPrice" - in the dbase, there is only RetailPrice and WholesalePrice so FinalPrice etc are more like extensions of the dbase fields. when i submit the form with nothing filled in, "FinalPrice" gets called (the

Excel Result not giving me anything, but it runs fine

人走茶凉 提交于 2019-12-11 13:37:48
问题 I use this AJAX to call my Excel Export action on the controller: $("#ExportToExcel").click(function () { // ajax call to do the export var urlString = "<%= System.Web.VirtualPathUtility.ToAbsolute("~/mvc/Indications.cfc/ExportToExcel")%>"; var Jsondata = { id: GetGUIDValue(), viewName: "<%= VirtualPathUtility.ToAbsolute("~/Views/Indications/TermSheetViews/Swap/CashFlows.aspx")%>", fileName: 'Cashflows.xls' } $.ajax({ type: "POST", url: urlString, data: Jsondata, success: function (data) { }

asp.net mvc 2 — losing authorization when RedirectToAction with JSON data

梦想的初衷 提交于 2019-12-11 12:10:12
问题 I'm refactoring some MVC code that originally used POST'ed form data . The form's fields are serialized using jquery's serialize() method and sent to an MVC controller Save Action that checks things out and redirects as appropriate (if errors in form values, redirect to the Edit Action, if fine then save and redirect to the Display Action). All actions are invoked via AJAX and return Partial Views. Everything works grand. Note: The site uses AD-based authorization, so users are prompted for

.NET MVC: How to use .NET controls with MVC?

て烟熏妆下的殇ゞ 提交于 2019-12-11 11:28:38
问题 I am very new to MVC. I've been learning to use plain HTML or HtmlHelpers, eg. for textbox, and get the value back in the Controller using Request.Form. But how do I use .NET controls with MVC? (eg. FileUpload) (The reason I ask is I am trying to use a custom control for uploading multiple files - it's Flajaxian File Uploader, if anyone knows about it. It works with webforms, but I have no idea how this thing is gonna work with MVC.) Thanks in advance 回答1: Further to what @Jon said this one

How to use multiple DisplayName attribute using Entity Framework and ASP.Net Mvc 2

筅森魡賤 提交于 2019-12-11 11:15:42
问题 Depending on where I use my Class, I want to be able to show a different DisplayName. I have the following class: [MetadataType(typeof(PortalMetaData))] [System.Web.Mvc.Bind(Exclude = "PortalId")] public partial class Portal { public Portal() { this.Created = DateTime.Now; } } public class PortalMetaData { [Required(ErrorMessage = "Portal name is required")] [StringLength(50, ErrorMessage = "Portal name must be under 50 characters")] public object PortalName { get; set; } [Required