我有一个关于ASP.NET MVC中的ModelBinding的问题(我正在使用MVC 2预览2)与继承相关.
假设我有以下接口/类:
interface IBase
class Base : IBase
interface IChild
class Child: Base, IChild
Run Code Online (Sandbox Code Playgroud)
我有一个自定义模型绑定器BaseModelBinder.
以下工作正常:
ModelBinders.Binders[typeof(Child)] = new BaseModelBinder();
ModelBinders.Binders[typeof(IChild)] = new BaseModelBinder();
Run Code Online (Sandbox Code Playgroud)
以下不起作用(绑定类型为Child的on对象):
ModelBinders.Binders[typeof(Base)] = new BaseModelBinder();
ModelBinders.Binders[typeof(IBase)] = new BaseModelBinder();
Run Code Online (Sandbox Code Playgroud)
有没有办法让基类的模型绑定器适用于所有继承的类?我真的不想为每个可能的继承类手动输入内容.
此外,如果可能,是否有办法覆盖特定继承类的模型绑定器?说我有这个工作,但我需要一个特定的Child2模型绑定器.
提前致谢.
在Chrome,FF和Safari(适用于Windows)上,我的页面看起来完全相同:

但在Mobile Safari(iPhone 4)上它是这样的:

我的问题是移动safari页面上的字体大小缺乏定义.请告诉我我的CSS /标记是如此搞砸了?
标记:
<body>
<div id="container">
<div id="header"><h1><a href="./DDD Blog_files/DDD Blog.htm" title="back to home page">DDD blog<span class="hidden"> (home)</span></a></h1></div>
<div class="newPost controls"><a href="http://localhost:1906/posts/update">Post something new</a></div>
<div class="post">
<h2><a href="http://localhost:1906/posts/2/title-of-the-first-blog-post">Title Of The First Blog Post</a></h2><span class="datetime" title="2010-12-15 00:00:00Z">1 month ago</span>
<div class="controls"><a href="http://localhost:1906/posts/update/2">edit</a></div>
<div class="body mattyMarkup">
<p>A massive paragraph of text should represent a blog entry. Every line of this should add to the enormous example which I am trying to convey. …Run Code Online (Sandbox Code Playgroud) 您将注意到:hover CSS用于网站测试的主要导航区域(徽标下的灰色栏)中的链接.ksischool.com在Firefox中工作正常,但IE7会删除底部的几个填充像素.为什么?
我是asp.net mvc的新手.
我正在使用Linq到Sql并试图做松散耦合的一切.
我有两张桌子:
我要做的是保存新闻并同时上传文件.
如何与他的文件一起创建新闻,将其保存到NewsFiles表?
Linq to Sql模型没问题,它包含对象NewsFile到News对象.
我的新闻表的具体存储库类(葡萄牙语中的noticia):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MagixCMS.Models
{
public class NoticiaRepository : INoticiaRepository
{
#region INoticiaRepository Members
magixcmsEntities _entities = new magixcmsEntities();
public noticia CreateNoticia(noticia noticiaToCreate)
{
_entities.AddTonoticiaSet(noticiaToCreate);
_entities.SaveChanges();
return noticiaToCreate;
}
public void DeletaNoticia(noticia noticiaToDelete)
{
var noticiaOriginal = GetNoticia(noticiaToDelete.Id);
_entities.DeleteObject(noticiaOriginal);
_entities.SaveChanges();
}
public noticia EditNoticia(noticia noticiaToEdit)
{
var noticiaOriginal = GetNoticia(noticiaToEdit.Id);
_entities.ApplyPropertyChanges(noticiaToEdit.EntityKey.EntitySetName, noticiaToEdit);
_entities.SaveChanges();
return noticiaToEdit;
}
public noticia GetNoticia(int id)
{
return …Run Code Online (Sandbox Code Playgroud) 在我的控制器类中,我将一些数据返回给我的视图,这一切都很好.
我可以这样做吗?
public ActionResult List()
{
while (true)
{
Thread.Sleep(3000);
return View("ListStatus", data);
}
}
Run Code Online (Sandbox Code Playgroud)
当然,上面的代码将不起作用,因为当运行return语句时函数存在.
我确信我可以在View中使用一些Ajax来每3秒从服务器上提取数据但是为了我目前的目的,我在上面的代码中尝试做的更容易
asp.net-mvc ×3
css ×2
ajax ×1
browser ×1
c# ×1
firefox ×1
html ×1
inheritance ×1
iphone ×1
linq-to-sql ×1
modelbinders ×1
safari ×1
standards ×1
xhtml ×1