小编den*_*s_n的帖子

异步html5验证

出于某种原因,当我使用异步请求时,不会显示html5验证消息.

在这里你可以看到一个例子.

http://jsfiddle.net/E4mPG/10/

setTimeout(function() {                
  ...
  //this is not working
  target.setCustomValidity('failed!');                
  ...
}, 1000);
Run Code Online (Sandbox Code Playgroud)

如果未选中复选框,则一切都按预期工作,但检查时,该消息不可见.

有人可以解释应该做什么吗?

javascript validation html5

10
推荐指数
1
解决办法
612
查看次数

MEF和ASP.NET MVC

我想在asp.net mvc中使用MEF.我写了以下控制器工厂:

public class MefControllerFactory : DefaultControllerFactory
{
    private CompositionContainer _Container;

    public MefControllerFactory(Assembly assembly)
    {
        _Container = new CompositionContainer(new AssemblyCatalog(assembly));
    }



    protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
    {
        if (controllerType != null)
        {
            var controllers = _Container.GetExports<IController>();

            var controllerExport = controllers.Where(x => x.Value.GetType() == controllerType).FirstOrDefault();

            if (controllerExport == null)
            {
                return base.GetControllerInstance(requestContext, controllerType);
            }

            return controllerExport.Value;
        }
        else
        {
            throw new HttpException((Int32)HttpStatusCode.NotFound,
                String.Format(
                    "The controller for path '{0}' could not be found or it does not implement IController.",
                    requestContext.HttpContext.Request.Path …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc mef

7
推荐指数
1
解决办法
4693
查看次数

Silverlight中的CallMethodAction不起作用

如何使用CallMethodAction?它不起作用.

<i:Interaction.Triggers>
  <i:EventTrigger>
    <ei:CallMethodAction MethodName="Init" />
  </i:EventTrigger>
</i:Interaction.Triggers>
Run Code Online (Sandbox Code Playgroud)

Init方法是视图模型

    public void Init()
    {
        if (_hasEmails != true)
        {
            IsBusy = true;

            _service.GetListAsync();
        }
    }
Run Code Online (Sandbox Code Playgroud)

silverlight

2
推荐指数
1
解决办法
2262
查看次数

Asp.net mvc 2模板没有前缀

给出以下视图模型:

class DetailsViewModel
{
   public HeaderViewModel Header {get;set;}
   public FooterViewModel Footer {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

我正在使用Header视图模型的编辑器模板:

<%: Html.EditorFor(x => x.Header) %>
Run Code Online (Sandbox Code Playgroud)

编辑器模板(EditorTemplates/HeaderViewModel.ascx)

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HeaderViewModel>" %>

<% ViewData.TemplateInfo.HtmlFieldPrefix = ""; %>

<%: Html.EditorFor(x => x.Search) %>
Run Code Online (Sandbox Code Playgroud)

结果:

<input type="text" value="" name="Search" id="Search" />
Run Code Online (Sandbox Code Playgroud)

如果我删除该行

<% ViewData.TemplateInfo.HtmlFieldPrefix = ""; %>
Run Code Online (Sandbox Code Playgroud)

结果是:

<input type="text" value="" name="Header.Search" id="Header_Search" />
Run Code Online (Sandbox Code Playgroud)

有没有另一种方法来实现相同 - 渲染没有前缀的控件的名称?

我在想一个帮手:

public static MvcHtmlString EditorWithoutPrefix<TModel, TValue>(
  this HtmlHelper<TModel> html, TValue value)
{
  var htmlHelper =... // create new HtmlHelper<TValue> and set it's …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-mvc-2

2
推荐指数
1
解决办法
1593
查看次数