我正在使用jQuery验证来验证表单.我的表单上有两个文本框,只有第一个会添加"此字段是必填项".信息.如果我从第一个类中删除"required"类,则第二个类将具有该消息.
HTML:
<form id="questionForm">
<div><input class="required" id="value" type="text" /></div>
<div><textarea class="required" id="description"></textarea></div>
<button type="submit">Save</button>
</form>
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
$("#questionForm").validate({ submitHandler: function() {
alert("valid");
}
});
Run Code Online (Sandbox Code Playgroud)
为什么只有一个被验证?
编辑:我正在使用jQuery验证插件1.7
编辑2:我正在使用MVC 3
我正在尝试将Code First与我的本地Sql Server 2008 R2实例一起使用.我创建了一个用户'dev',可以使用Sql Managment Studio登录并创建数据库.问题是我在EntityFramework中尝试使用DbContext创建数据库时不断收到错误消息.这是错误消息:
"建立与SQL Server的连接时发生与网络相关或特定于实例的错误.未找到服务器或无法访问服务器.验证实例名称是否正确以及SQL Server是否配置为允许远程连接.SQL网络接口,错误:26 - 找到指定的服务器/实例时出错"
错误消息我检查了我的Sql Server,它确实允许远程连接.
我用以下代码抽象了我的系统并得到了同样的错误:
namespace CodeFirstConsole
{
public class Program
{
static void Main(string[] args)
{
var db = new MyContext();
try { Console.WriteLine(db.Parents.Count()); }
catch (Exception) { throw; }
Console.Read();
}
}
internal class MyContext : DbContext
{
public DbSet<ParentObject> Parents { get; set; }
public DbSet<ChildObject> Children { get; set; }
public MyContext()
{
this.Database.Connection.ConnectionString =
"Data Source=.;Database=ConsoleTest;Initial Catalog=ConsoleTest;User ID=dev;Password=dev;";
}
}
internal class ParentObject
{
public …
Run Code Online (Sandbox Code Playgroud) 我有一个刷子,用于为标题的背景着色.我喜欢画笔的外观,但希望它在底部三分之一处淡出透明.任何想法如何做到这一点?
<LinearGradientBrush
x:Key="HeaderBackgroundBrush"
EndPoint=".5,1"
StartPoint="1,0">
<GradientStop Color="#006699" Offset="1"/>
<GradientStop Color="#80A8CC" Offset="0.5"/>
</LinearGradientBrush>
Run Code Online (Sandbox Code Playgroud) 每当我有一个带有空格的Json字符串对象时,我会收到以下错误.
Java的:
String jString = getResources().getString(R.string.event);
JSONObject object = new JSONObject(jString);
Run Code Online (Sandbox Code Playgroud)
JSON:
<resources>
<string name="event">
{"Array":[{"Name":"One two three"},{"Name":"Two"},{"Name":"Three"}]}
</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
我收到以下消息:
09-06 22:35:08.214: WARN/System.err(1079): org.json.JSONException: Unterminated object at character 21 of {Array:[{Name:One two three},{Name:Two},{Name:Three}]}
Run Code Online (Sandbox Code Playgroud)
这没有任何问题:
<resources>
<string name="event">
{"Array":[{"Name":"One"},{"Name":"Two"},{"Name":"Three"}]}
</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
我引用了一些错误的东西吗?
编辑:通过我自己的帖子阅读我注意到错误消息没有任何关于字符串对象值的引号.所以我在xml字符串中更改了"to",它运行正常.知道怎么让它不删除任何引号?
我有一个ASP.Net MVC Kendo UI组合框,它被数据绑定到一个包含1000个记录的表.我已将MinLength属性设置为5,因此我只返回相关结果.问题是,用户可能需要一起更改文本值.有没有办法告诉控件刷新?
这是控件的代码......
@(Html.Kendo().ComboBoxFor(x => x.Product)
.Name("Product")
.DataTextField("Name") // Display value
.DataValueField("Id") //Return value
.MinLength(5)
.AutoBind(false)
.Suggest(true)
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("Products", "Home").Data("onGetProducts");
});
})
)
Run Code Online (Sandbox Code Playgroud) asp.net-mvc kendo-ui kendo-grid kendo-combobox kendo-asp.net-mvc
使用DirectionsService时,如何向directionsRenderer添加mouseover事件侦听器?
我知道如何将侦听器添加到直线但似乎无法在directionsRenderer中找到该对象.
例如,这有效:
function getStraightLine(coordinates) {
if (progress.length == 0)
progress = coordinates;
else
progress.push(coordinates[1]);
updateDistance();
var line = new google.maps.Polyline({
path: coordinates,
strokeColor: "#FF0000",
strokeOpacity: .5,
strokeWeight: 2,
map: map
});
google.maps.event.addListener(line, 'mouseover', function(){
alert("moused over straight line!");
});
return line;
}
Run Code Online (Sandbox Code Playgroud)
但这不是:
function getDirectionsPath(coordinates) {
var directionsPath = new google.maps.DirectionsRenderer();
directionsPath.setMap(map);
var request = {
origin: coordinates[0],
destination: coordinates[1],
travelMode: google.maps.TravelMode.WALKING
};
directionsService.route(request, function (result, status) {
if (status == google.maps.DirectionsStatus.OK) {
var coordinates = result.routes[0].overview_path;
if (progress.length …
Run Code Online (Sandbox Code Playgroud) c# ×2
javascript ×2
android ×1
asp.net-mvc ×1
brushes ×1
google-maps ×1
gradient ×1
graphics ×1
jquery ×1
json ×1
kendo-grid ×1
kendo-ui ×1
wpf ×1