asp.net-mvc-2

CheckBoxList multiple selections: how to model bind back and get all selections?

橙三吉。 提交于 2019-12-22 10:53:21
问题 This code: Html.CheckBoxList(ViewData.TemplateInfo.HtmlFieldPrefix, myList) Produces this mark-up: <ul><li><input name="Header.h_dist_cd" type="checkbox" value="BD" /> <span>BD - Dist BD Name</span></li> <li><input name="Header.h_dist_cd" type="checkbox" value="SS" /> <span>SS - Dist SS Name</span></li> <li><input name="Header.h_dist_cd" type="checkbox" value="DS" /> <span>DS - Dist DS Name</span></li> <li><input name="Header.h_dist_cd" type="checkbox" value="SW" /> <span>SW - Dist SW Name <

Silverlight 4.0 + MVC 2.0 + WCF RIA Services + EF 4.0 = Load Error

六月ゝ 毕业季﹏ 提交于 2019-12-22 10:51:39
问题 I'm trying to buid a site with the following: VS 2010 (for the updated WCF RIA Services) Silverlight 4.0 (packaged with WCF RIA Services). MVC 2 EF 4.0 I am setting it up so that the public facing pages will be html from MVC, but the administration portion will be a silverlight navigation application using using WCF RIA Services for data access. When I create the silverlight application within a webforms application, it works (I am able to add a datagrid and retrieve data using EF 4.0 and WCF

MVC2 Modelbinder for List of derived objects

故事扮演 提交于 2019-12-22 10:49:03
问题 I want a list of different (derived) object types working with the Default Modelbinder in Asp.net MVC 2. I have the following ViewModel: public class ItemFormModel { [Required(ErrorMessage = "Required Field")] public string Name { get; set; } public string Description { get; set; } [ScaffoldColumn(true)] //public List<Core.Object> Objects { get; set; } public ArrayList Objects { get; set; } } And the list contains objects of diffent derived types, e.g. public class TextObject : Core.Object {

ASP .NET VirtualPathProvider HttpCompileException

允我心安 提交于 2019-12-22 10:39:32
问题 I have a VirtualPathProvider that is loading my aspx file content from a DB. All seems to be well and good except when my aspx file has a reference to a namespace or assembly that is not explicitly mentioned in my web.config. The solution seems easy right? Add assembly and import directives to the page... But that doesn't seem to work. I still get the following HttpCompileException: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\app.server\70480a40\2a773b44\App_Web

Find element on site from a fancybox iframe

徘徊边缘 提交于 2019-12-22 10:32:01
问题 I'm trying to update a element on my site from a fancybox. In the fancybox i do a $.post() and get back html data that i want to populate in a div on my page. I open up a iframe window with html and this script below is in that iframe . It cant find it from the fancybox so anybody got idea or solution on how to reach a element thats not inside the fancybox iframe ? $('.add-to-cart').click(function () { var $this = $(this).closest('form'); $.post($this.attr('action'), { quantity: $this.find('

Very simple single user login in ASP.NET MVC2?

岁酱吖の 提交于 2019-12-22 10:01:38
问题 I'm building my site, and I want to restrict a part of my site (The admin parts) from normal public display. I am using LINQ for database access. I have a Service class to handle calls to the database through LINQ I have the whole site running, except for the Login part. So far I have only been able to find examples using MembershipProvider and/or RoleProviders etc. And to be honest, it does seem like too much work for what I want. All this has to do is to let you in if you type the correct

ModelBindingContext ModelName

别等时光非礼了梦想. 提交于 2019-12-22 09:39:07
问题 Can anyone explain where the ModelName gets populated from? Looked in MSDN documentation and no explaination here. I am creating a custom model binder and within it I get null for the following: var result = bindingContext.ModelName); 回答1: The ModelBindingContext object is created and populated by whoever calls into the BindModel() method. If the model is coming in as an argument to your action method, this is done by ControllerActionInvoker.GetParameterValue(), and the ModelName property

EF4: how to use a generic repository pattern ?

孤者浪人 提交于 2019-12-22 09:38:25
问题 I'm trying to streamline my existing repos by using a generic repo I can subclass from. The problem is that I can't figure out how to write a few of my base class methods. I currently have: public interface IRepository<T> : IDisposable where T : class { IQueryable<T> GetAll(); T GetSingle(int id); T GetSingle(string slug); void Save(T entity); } public class HGRepository<T> : IRepository<T> where T : class { protected HGEntities _siteDB; protected IObjectSet<T> _objectSet; public HGRepository

.NET MVC : Pass back complex object or list array from view to controller

霸气de小男生 提交于 2019-12-22 09:26:41
问题 I want to pass a list array from the View to the controller on submission of the form. I can pass back simple values by using the Html.hidden() function. But how does one pass back a complex object or a List array 回答1: You can either use Json or look into the following example http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/ 回答2: You can pass back a list within a view model using Html.hidden for each element of a list. The list property in your

asp.net mvc datatable

心不动则不痛 提交于 2019-12-22 08:55:47
问题 How can I pass datatable to the mvc view How would I iterate over it in the view 回答1: In your controller: public ActionResult Index() { DataTable dt = new DataTable(); return View(dt); } In your View: Just make your model of type DataTable Inherits="System.Web.Mvc.ViewPage<System.Data.DataTable>" To iterate over it: <% foreach (System.Data.DataRow row in Model.Rows) { %> <%= row["column"].ToString(); %> <%}%> 来源: https://stackoverflow.com/questions/2794831/asp-net-mvc-datatable