我使用asp.net和Web表单.在我的项目中,我有asmx web服务
[WebMethod]
public string GetSomething()
{
// avoid circual reference(parent child)
List<RetUsers> res = repo.GetAllUser().Select(c => new RetUsers {User_ID = c.User_ID,User_Name = c.User_Name,Date_Expire = c.Date_Expire }).ToList();
string res1 = res.ToJson();
// extension methods
return res.ToJson();
}
Run Code Online (Sandbox Code Playgroud)
结果就是这种格式.
[
{"User_ID":1,"User_Name":"Test 1","Date_Expire":null},
{"User_ID":2,"User_Name":"Test 2","Date_Expire":null}
]
Run Code Online (Sandbox Code Playgroud)
如何在$ .ajax sucess中附加标记此结果以获得此输出:
1 - 测试1,2 - 测试2.
我在我的模型中有这个字段
[DataType(DataType.DateTime)]
[Required(ErrorMessage = "Expire is required")]
public DateTime Expire
{
get;
set;
}
Run Code Online (Sandbox Code Playgroud)
在我看来
@Html.EditorFor(model => model.Expire))
@Html.ValidationMessageFor(model => model.Expire)
Run Code Online (Sandbox Code Playgroud)
我创建了DataTime EditorTemplates
@inherits System.Web.Mvc.WebViewPage<System.DateTime>
@Html.TextBox("", (Model.ToShortDateString()), new { @class = "datePicker" })
<script type='text/javascript'>
$(document).ready(function () {
$(".datePicker").datepicker({
// buttonImage: "/content/images/calendar.gif",
// showOn: "both",
// defaultDate: $("#calendar-inline").attr('rel')
showAnim: 'slideDown',
dateFormat: 'dd/mm/yyyy'
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
当我尝试创建新项目时,我有此错误消息
传递到字典中的模型项为null,但此字典需要"System.DateTime"类型的非null模型项
我试试
Model.HasValue ? Model.Value.ToString("MM/dd/yyyy") : DateTime.Today.ToShortDateString()
Run Code Online (Sandbox Code Playgroud)
但我没有进行模型价值检查
我正在使用Jquery UI和Autocomplete func.(Combobox),我对这部分感兴趣.
$("<button> </button>")
.attr("tabIndex", -1)
.attr("title", "Show All Items")
.insertAfter(input)
.button({
icons: {
primary: "ui-icon-triangle-1-s"
},
text: false
Run Code Online (Sandbox Code Playgroud)
我的问题是当我使用ASP.net时,这个按钮做了PostBack,但我不需要这个,因为我的项目列表随后消失了.如何覆盖按钮的此行为.谢谢
我尝试使用MVC3创建像痕迹导航一样的东西.
当用户转到页面时,他有例如:Home(id = 1),About(id = 2)和Hello(id = 3)链接.我从数据库获得这些链接.当我点击Home时,我转到数据库并获得一组新链接:Home - Link1(id = 3),Link2(id = 4)等.
如果我没有数据库中的任何内容,那么我会显示一些页面内容.
主页 - Link1 - 其他一些人
页面内容
我怎样才能做到这一点?