我有一个带有以下正则表达式的电话号码字段:
[RegularExpression(@"^[0-9]{10,10}$")]
Run Code Online (Sandbox Code Playgroud)
这个检查输入正好是10个数字字符,我应该如何更改此正则表达式以允许空格使以下所有示例都有效
1234567890
12 34567890
123 456 7890
Run Code Online (Sandbox Code Playgroud)
干杯!
我正在尝试淘汰映射样本,并认为我几乎就在那里.我似乎无法在viewModel.foos中添加新的Foo - 有谁能看到我在这里错过的内容?
var Foo = function (data) {
var self = this;
self.id = data.id;
self.Name = ko.observable(data.Name);
}
var dataMappingOptions = {
key: function(data) {
return data.id;
},
create: function (options) {
return new Foo(options.data);
}
};
var viewModel = {
foos: ko.mapping.fromJS([]),
loadInitialData: function () {
ko.mapping.fromJS(serverData, dataMappingOptions, viewModel.foos);
},
loadUpdatedData: function () {
ko.mapping.fromJS(serverData, dataMappingOptions, viewModel.foos);
}
};
viewModel.addFoo = function () {
viewModel.foos.push(ko.mapping.fromJS(new Foo()));
viewModel.loadUpdatedData();
}
<ul data-bind="template: {name: 'TopTemplate'}"></ul>
<script type="text/html" id="TopTemplate">
<li><span>Result</span>
<ul …Run Code Online (Sandbox Code Playgroud) 我有一个全新安装的umbraco 4.11.3我正在尝试进行一个简单的控制器测试,但是有些事情对我来说是错误的.我创建了一个没有匹配模板的文档类型"Demo".然后基于该Document类型调用名为"Demo"的内容项并更改此配置设置(defaultRenderingEngine - > MVC)我添加了一个带有以下代码的新控制器.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Models;
namespace FrontEnd.Controllers
{
public class DemoController : Umbraco.Web.Mvc.RenderMvcController
{
//
// GET: /Demo/
public ActionResult Index(RenderModel model)
{
return base.Index(model);
}
public ActionResult Demo(RenderModel model)
{
return View(model);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
The current request for action 'Index' on controller type 'DemoController' is ambiguous between the following action methods:
System.Web.Mvc.ActionResult Index(Umbraco.Web.Models.RenderModel) on type FrontEnd.Controllers.DemoController
System.Web.Mvc.ActionResult Index(Umbraco.Web.Models.RenderModel) on type Umbraco.Web.Mvc.RenderMvcController
Exception Details: System.Reflection.AmbiguousMatchException: The …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个自托管的OWin应用程序(使用VS2012)-我认为它已经关闭,因为我可以从包含.csproj的目录中运行OwinHost.exe,并且应用程序可以从localhost:5000正确进行服务。我创建了一个默认的nuspec文件,并添加了以下内容
<files>
<file src="bin\*.dll" target="bin" />
<file src="views\home\home.html" target="content" />
<file src="web.config" target="content" />
</files>
Run Code Online (Sandbox Code Playgroud)
在AssemblyInfo.cs中
[assembly: OwinStartup(typeof(TestA.Startup))]
Run Code Online (Sandbox Code Playgroud)
当我安装软件包(nuget install mypackage)时,出现以下错误...
从默认端口开始:5000 ...
Error: System.ArgumentException
No conversion available between
System.Func`2[System.Collections.Generic.IDictionary`2[System.String,System.Object],
System.Threading.Tasks.Task] and Microsoft.Owin.OwinMiddleware.
Parameter name: signature
Run Code Online (Sandbox Code Playgroud)
让我知道您是否需要更多信息
干杯!
我有一个自托管服务堆栈应用程序,我正在使用Facebook Oath和Redis - Facebook和redis方面的东西似乎正在工作,即.当我访问
abc.com/auth/facebook
Run Code Online (Sandbox Code Playgroud)
自定义用户会话将在OnAuthenticated方法中填充.Redis缓存的数据保持正确.所以这么好
我遇到的问题是了解如何在后续请求中检索此CustomUserSession.从oauth重定向页面开始,"/ About-Us"是我想要检索会话值的地方,但它始终为null
[DataContract]
public class CustomUserSession : AuthUserSession
{
[DataMember]
public string CustomId { get; set; }
public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary<string, string> authInfo)
{
// receiving session id here and can retrieve from redis cache
}
public override bool IsAuthorized(string provider)
{
// when using the [Authenticate] attribute - this Id is always
// a fresh value and so doesn't exist in cache and cannot be auth'd
string …Run Code Online (Sandbox Code Playgroud) 虽然直接通过互联网访问私有子网是不恰当的 - 假设我只是运行开发堆栈并需要通过SSH快速和脏访问私有实例.这可以通过Route Tables和Nat GW实现,还是我唯一可以选择公共子网中的第二个实例访问私有实例?
我有一个修改过的T4模板,它可以从我的edmx构建类,并且除了派生类之外它还能顺利运行.
Product : BaseItem // works fine as do all top level classes
TranslatedProduct : Product : BaseItem // dang
Run Code Online (Sandbox Code Playgroud)
我对如何以及在何处有条件地将T4模板设置为忽略感到困惑:在派生类的情况下BaseItem - 即
TranslatedProduct : Product
Run Code Online (Sandbox Code Playgroud)
例如:
<#=Accessibility.ForType(entity)#> <#=code.SpaceAfter(code.AbstractOption(entity))#>partial class <#=code.Escape(entity)#><#=code.StringBefore(" : ", code.Escape(entity.BaseType))#> : BaseItem
Run Code Online (Sandbox Code Playgroud)
在我的脑海里,我想象它 -
if(code.Escape(entity.BaseType).Equals(string.empty)
{
<#=Accessibility.ForType(entity)#> <#=code.SpaceAfter(code.AbstractOption(entity))#>partial class <#=code.Escape(entity)#> : BaseItem
}
else
{
<#=Accessibility.ForType(entity)#> <#=code.SpaceAfter(code.AbstractOption(entity))#>partial class <#=code.Escape(entity)#><#=code.StringBefore(" : ", code.Escape(entity.BaseType))#>
}
Run Code Online (Sandbox Code Playgroud)
但是我收到了语法错误,所以我想看看是否还有其他人试过这个,如果我走的是正确的道路
我正在使用淘汰映射插件,之前我会像这样设置订阅
self.selectedProduct.subscribe(function (name) {
}
but I'm unsure of how to do this in this format below. The message I get is
Run Code Online (Sandbox Code Playgroud)
"失踪:财产ID后"
var viewModel = {
products: ko.mapping.fromJS([]),
productOptions: ko.mapping.fromJS([]),
productOptions.subscribe = function (name) {
alert('somthing change');
},
loadInitialData: function () {
ko.mapping.fromJS(serverData, viewModel.productOptions);
}
}
Run Code Online (Sandbox Code Playgroud) 关注railscast#196但使用Rails 4 - 我在尝试从问题父模型中删除答案时遇到了问题.
未允许的参数:_destroy
_answer_fields.html.erb
<fieldset>
<%= f.text_field :response %>
<%= f.hidden_field :_destroy %>
<%= link_to "remove" , "#", class: "remove_fields" %>
</fieldset>
Run Code Online (Sandbox Code Playgroud)
question.rb
accepts_nested_attributes_for :questions, :allow_destroy => true
Run Code Online (Sandbox Code Playgroud)
surveys_controller.rb
def survey_params
params.require(:survey).permit(:name, :questions_attributes => [:id, :content, :answers_attributes => [:id, :response]])
end
Run Code Online (Sandbox Code Playgroud)
我正在删除表单上的字段点击罚款,但记录尚未删除.
谢谢
编辑: JS设置隐藏变量
jQuery ->
$(document).on 'click' , ".remove_fields" , (event) ->
$(this).prev('input[type=hidden]').val('1')
$(this).closest('fieldset').hide()
event.preventDefault()
Run Code Online (Sandbox Code Playgroud) c# ×4
.net ×2
knockout.js ×2
t4 ×2
amazon-vpc ×1
asp.net-mvc ×1
katana ×1
owin ×1
regex ×1
servicestack ×1
ssh ×1
umbraco ×1