日期:2014-05-17 浏览次数:20384 次
<div class="editor-field">
@foreach (SelectListItem item in (List<SelectListItem>)ViewData["CityList"])
{
@Html.CheckBox("SomeParas", item.Selected, new { value=item.Value})
@Html.Label(item.Text);
}
</div>
protected void BindCheckbox(RegisterModel model)
{
List<SelectListItem> cityselectList = new List<SelectListItem>();
cityselectList.Add(new SelectListItem { Text = "所有", Value = "0", Selected = false });
cityselectList.Add(new SelectListItem { Text = "宁波", Value = "88", Selected = false });
ViewData["CityList"] = cityselectList;
}
public ActionResult Register()
{
BindCheckbox(null);
return View();
}
[HttpPost]
public ActionResult Register(RegisterModel model,string[] SomeParas)
{
//if (ModelState.IsValid)
//{
// // 尝试注册用户
// MembershipCreateStatus createStatus;
// Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
// if (createStatus == MembershipCreateStatus.Success)
// {
// FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
// return RedirectToAction("Index", "Home");