<%: Html.ActionLink("Edit", "Edit", new { id = Model.StuId })%>
<%: Html.ActionLink("invokeTest","method1","Test",new {id1="11",id2="22",id3="33"}) %>
[AsyncTimeout(6000)]
public void method1Async(string id1, string id2, string id3, string id4 = "4")
{
Thread.Sleep(3000);
}
public void method1Completed(string id1,string id2,string id3,string id4 = "4") {
Response.Write("id1: " + id1 + " id2 : " + id2 + " id3 :" + id3 + "id4: " + id4);
}
<% using (Html.BeginForm())
{ %>
<% } %>
[HttpPost]
public ActionResult Details(string a) {
string aa = a;
return View();
}
<% Html.BeginForm();%>
<% Html.EndForm(); %>
<%: Html.HiddenFor(m => m.Name) %>
controller使用linq直接赋值:
var q = svm.StudentList;
var ids = (from q1 in q select new SelectListItem() { Text = q1.name });
ViewData["stuname"] = ids;
<%:Html.DropDownList("stuname") %>
<%: Html.ListBox("stuname") %>
<%: Html.Password("pwd") %>
<%: Html.Password("pwd",Model.Name) %>
<%: Html.RadioButton("radio", "red", false) %>
<%: Html.RadioButton("radio", "yellow", true) %>
<% Html.RenderPartial("ajaxTest"); %>
<% Html.RenderPartial("ajaxTest",Model); %>
<%: Html.TextArea("ta","hello , world",10,8,new {@class="aaa"}) %>
html:
常用验证规则:
Required:必须输入,不能为空
StringLength:字符串的长度不能大于设置的长度
Range:数字的可输入范围
RegularExpression:正则表达式匹配
Required 和 StringLength 为限制条件
[Required(ErrorMessage="stu no is not null")]
[StringLength(10,ErrorMessage="length is invalid")]
public global::System.String stuNo
{
get
{
return _stuNo;
}
set
{
if (_stuNo != value)
{
OnstuNoChanging(value);
ReportPropertyChanging("stuNo");
_stuNo = StructuralObject.SetValidValue(value, false);
ReportPropertyChanged("stuNo");
OnstuNoChanged();
}
}
}
if (ModelState.IsValid)
{
svm.AddStudent(s);
return Index();
}
else
{
return View("Create");
}
<%: Html.ValidationSummary("something is wrong") %>
<%: Html.TextBoxFor(model => model.stuNo) %>
<%: Html.ValidationMessageFor(model => model.stuNo) %>