将值绑定到下拉列表并使用敲除验证时,即使我的敲除验证设置说明,也会始终显示错误消息messagesOnModified: true.
HTML
<input type="text" data-bind="value: Name" />
<br />
<select data-bind="value: State">
<option value="">Select a state...</option>
<option value="NY">New York</option>
<option value="NJ">New Jersey</option>
</select>
Run Code Online (Sandbox Code Playgroud)
JS
var ViewModel = function () {
var self = this;
self.Name = ko.observable().extend({
required: { message: "You must enter a name." }
});
self.State = ko.observable().extend({
required: { message: "You must select a state." }
});
self.Errors = ko.validation.group(self);
}
ko.validation.configure({
messagesOnModified: true,
insertMessages: true
});
ko.applyBindings(new ViewModel(), document.body);
Run Code Online (Sandbox Code Playgroud)
并且jsfiddle显示文本框和下拉列表之间的区别:http://jsfiddle.net/f7v4m/ …
我有一个WCF服务定义为:
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class Service
{
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public string HelloWorld()
{
return "Hello World";
}
}
Run Code Online (Sandbox Code Playgroud)
我的Web.Config文件:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true"/>
</webHttpBinding>
</bindings>
<services>
<service name="Service">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="Service" behaviorConfiguration="webHttpBehavior"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我希望能够在我的WCF服务中访问ASP .Net会话变量,并且我希望WCF服务返回JSONP数据,但是即使使用这个简单的服务,浏览到../Service.svc/HelloWorld我得到了一个400 Bad Request错误.
有人能指出我正确的方向吗?