1、@Scripts.Render("~/bundles/kindeditor");@Styles.Render("~/Css/") //(加载)引用bundles/kindeditor/kindeditor.js文件 @using System.Web.Optimization
2、@Html.TextArea("Information", new { style = "width:800px;height:400px" }) (@Html.Raw())
3、HashTable hash=new HashTable();
hash["id"]=1; hash["url"]="../Home/Index";
return Json(hash,""text/html;charset=UTF-8"");
4、$.post(‘@Url.Action("GetSth")‘,{},function(data) { 标注:GetSth为相同Controler下面的方法
if (data.msg) {
alert("请求成功一次");
} else {
alert("请求次数过多");
}
});
5、异步表单:
1>>>>>
@using (Ajax.BeginForm("GetDateTime", "Html", new AjaxOptions()
{
HttpMethod = "post", //传输方式
OnSuccess = "suc", //加载成功调用的js方法
OnFailure="err", //出错调用的js方法
LoadingElementId = "imgLoad" //请求所现实的元素
}))
{
<input type="text" name="txtName" />
<input type="submit" />
<div id="imgLoad">loding....</div>
}
2>>>>>
<script type="text/javascript">
function suc(resText) {
alert(resText);
};
var xhr=new XMLHttpRequest();//ActiveXObject("Msxml2.XmlHttp"); ActiveXObject("Microsoft.XmlHttp");
function err(xhr) {
alert(xhr.readyState)
}
</script>
3>>>>>
public ActionResult GetDateTime()
{
string str =Request.Form["txtName"];
System.Threading.Thread.Sleep(2000);
return Content(DateTime.Now + "," + str);
}
IEnumerable<T> sources.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();