asp.net-mvc-3

Object template - Html.Display using ViewBag

三世轮回 提交于 2020-01-23 16:27:06
问题 I've got following display template for object (source): @model object @if (Model == null) { @ViewData.ModelMetadata.NullDisplayText } else if (ViewData.TemplateInfo.TemplateDepth > 1) { @ViewData.ModelMetadata.SimpleDisplayText } else { foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForDisplay && !ViewData.TemplateInfo.Visited(pm))) { if (prop.HideSurroundingHtml) { @Html.Display(prop.PropertyName) } else { <div> <strong>@prop.GetDisplayName():</strong> @Html

How do I use WCF reference with MVC3 (razor) model?

微笑、不失礼 提交于 2020-01-23 12:06:28
问题 I have a WCF Service and a MVC3 (razor) web site. All my data comes from the WCF Service . I have my controllers and views but, how do I use the model with this structure ? for now, I call my method from the service with a DataController and I called them in the Controllers.. Better solution ? 回答1: Do you want to access a WCF service from your Model? Ouch... Stick to the Controller. Controllers interact with services, models don't. 回答2: 1.You created web reference to your service - and

How do I use WCF reference with MVC3 (razor) model?

依然范特西╮ 提交于 2020-01-23 12:05:47
问题 I have a WCF Service and a MVC3 (razor) web site. All my data comes from the WCF Service . I have my controllers and views but, how do I use the model with this structure ? for now, I call my method from the service with a DataController and I called them in the Controllers.. Better solution ? 回答1: Do you want to access a WCF service from your Model? Ouch... Stick to the Controller. Controllers interact with services, models don't. 回答2: 1.You created web reference to your service - and

Creating MVC3 ValueProviderFactories That Require Type Information?

坚强是说给别人听的谎言 提交于 2020-01-23 12:05:37
问题 I'm attempting to write a Protobuf ValueProviderFactory for ASP MVC3. I've managed to work out how to add the factories, but now I've stumbled on a more pressing problem. Here is where the current serialization takes place in JsonValueProviderFactory.cs JavaScriptSerializer serializer = new JavaScriptSerializer(); object jsonData = serializer.DeserializeObject(bodyText); return jsonData; So the deserialization is accomplished without any type information? What sort of object does

Delete white spaces in textbox when copy pasted with jquery

女生的网名这么多〃 提交于 2020-01-23 08:02:53
问题 I've a textbox of order id(7 digits), which in normal cases you copy paste from email to the textbox, many times you accidently copy one or two white spaces which causing annoying validation error. I want jquery code in my Layout\MasterPage that does't allow writing white spaces and when copy paste (with keyboard or mouse) numbers with white spaces removes the spaces and keeps the numbers only. The above should happen only on textboxes with class white-space-is-dead 回答1: Do $('.white-space-is

How to override the ASP.NET MVC 3 default model binder to resolve dependencies (using ninject) during model creation?

天大地大妈咪最大 提交于 2020-01-23 05:56:35
问题 I have an ASP.NET MVC 3 application that uses Ninject to resolve dependencies. All I've had to do so far is make the Global file inherit from NinjectHttpApplication and then override the CreateKernel method to map my dependency bindings. After that I am able to include interface dependencies in my MVC controller constructors and ninject is able to resolve them. All that is great. Now I would like to resolve dependencies in the model binder as well when it is creating an instance of my model,

Unity IoC and MVC 3 Beta - Passing IRepository to Controller Constructor

给你一囗甜甜゛ 提交于 2020-01-23 03:06:08
问题 Did something change in MVC 3? I have tried all the examples on the Internet for setting up Unity as my IoC Container, but I keep getting an error saying that Unity cannot resolve my UserController. Here is my constructor on my UserController: public UserController(IUserService userService) { _userService = userService; } I have the IUserService registered, that is not the problem. I keep getting errors, no matter what example I try. Does anyone have a good tutorial, or code, that works with

Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties

时光怂恿深爱的人放手 提交于 2020-01-23 03:05:19
问题 I'm working on building a custom module in Orchard CMS, and I have the following Controller Action: public ActionResult Inventory() { var models = _repository.Get<MyModel>(); return View(new MyViewModel() { MyModels = models.ToList() }); } Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be. The exception is method get_Id should be 'public/protected virtual' or 'protected

Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties

[亡魂溺海] 提交于 2020-01-23 03:05:01
问题 I'm working on building a custom module in Orchard CMS, and I have the following Controller Action: public ActionResult Inventory() { var models = _repository.Get<MyModel>(); return View(new MyViewModel() { MyModels = models.ToList() }); } Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be. The exception is method get_Id should be 'public/protected virtual' or 'protected

Orchard Custom Module - Model being picked up by NHibernate - Requiring virtual properties

旧巷老猫 提交于 2020-01-23 03:04:26
问题 I'm working on building a custom module in Orchard CMS, and I have the following Controller Action: public ActionResult Inventory() { var models = _repository.Get<MyModel>(); return View(new MyViewModel() { MyModels = models.ToList() }); } Now, when Orchard builds this, an exception occurs, because NHibernate has picked up MyModel because its being looked at as a PartRecord, which I do not want it to be. The exception is method get_Id should be 'public/protected virtual' or 'protected