他妈的一定要引用:
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
才能开始下面编码:
<div class="person_center">
<div class="person_center_s" id="logincontent">
<span class="person_center_img1"></span>
<span class="person_center_dushu">读书个人中心:</span>
<span class="person_center_zhanghao">账号</span>
<span class="person_center_input"><input type="text" /></span>
<span class="person_center_mima">密码</span>
<span class="person_center_input"><input type="password" /></span>
@Ajax.ActionLink("登 录", "Login", null, null, new AjaxOptions { UpdateTargetId = "logincontent", HttpMethod = "Get" })
<a href="#" class="person_center_a">找回密码</a>|<a href="#" class="person_center_a">注册通行证</a>
<a class="person_center_right" href="#">充值</a>
</div>
</div>
<div class="person_center_s" id="logincontent">
<span class="person_center_img1"></span>
<span class="person_center_dushu">读书个人中心:</span>
<span class="person_center_zhanghao">账号</span>
<span class="person_center_input"><input type="text" /></span>
<span class="person_center_mima">密码</span>
<span class="person_center_input"><input type="password" /></span>
@Ajax.ActionLink("登 录", "Login", null, null, new AjaxOptions { UpdateTargetId = "logincontent", HttpMethod = "Get" })
<a href="#" class="person_center_a">找回密码</a>|<a href="#" class="person_center_a">注册通行证</a>
<a class="person_center_right" href="#">充值</a>
</div>
</div>
对应的控制器编码:
public string Login()
{
return "欢迎:reflower";
}
{
return "欢迎:reflower";
}
另, 我设计的几种登录模式
1: AJAX异步登录(没有办法传当前页面实体给控制器)
2: POST绑定页面实体登录(会跳转到新页面窗口)
3: AJAX-POST表单异步登录 (以上几种问题都解决)
@model net91com.BookPandaRes.UI.Models.LoginUser
@using (Html.BeginForm())
{
<div class="person_center">
<div class="person_center_s" id="logincontent">
<span class="person_center_img1"></span>
<span class="person_center_dushu">读书个人中心:</span>
<span class="person_center_zhanghao">账号</span>
@using(Ajax.BeginForm("Login", new AjaxOptions { UpdateTargetId = "logincontent", HttpMethod = "Post" })){
<span class="person_center_input">@Html.TextBoxFor(a => a.Account)</span>
<span class="person_center_mima">密码</span>
<span class="person_center_input">@Html.PasswordFor(a => a.Password)</span>
<input type="submit" value="异步登录" />
}
@Ajax.ActionLink("登 录", "Login", null, new { user = Model }, new AjaxOptions { UpdateTargetId = "logincontent", HttpMethod = "Post" })
<input type="submit" value="登陆" />
<a href="#" class="person_center_a">找回密码</a>|<a href="#" class="person_center_a">注册通行证</a>
<a class="person_center_right" href="#">充值</a>
</div>
</div>
}
@using (Html.BeginForm())
{
<div class="person_center">
<div class="person_center_s" id="logincontent">
<span class="person_center_img1"></span>
<span class="person_center_dushu">读书个人中心:</span>
<span class="person_center_zhanghao">账号</span>
@using(Ajax.BeginForm("Login", new AjaxOptions { UpdateTargetId = "logincontent", HttpMethod = "Post" })){
<span class="person_center_input">@Html.TextBoxFor(a => a.Account)</span>
<span class="person_center_mima">密码</span>
<span class="person_center_input">@Html.PasswordFor(a => a.Password)</span>
<input type="submit" value="异步登录" />
}
@Ajax.ActionLink("登 录", "Login", null, new { user = Model }, new AjaxOptions { UpdateTargetId = "logincontent", HttpMethod = "Post" })
<input type="submit" value="登陆" />
<a href="#" class="person_center_a">找回密码</a>|<a href="#" class="person_center_a">注册通行证</a>
<a class="person_center_right" href="#">充值</a>
</div>
</div>
}
浙公网安备 33010602011771号