我的 cshtml 网页上有 2 个表单。一
@if (WebSecurity.IsAuthenticated) {
<text>
Hello, <a class="email" href="~/Account/Manage" title="Manage">@WebSecurity.CurrentUserName</a>!
<form id="logoutForm" action="~/Account/Logout" method="post">
@AntiForgery.GetHtml()
<a href="javascript:document.getElementById('logoutForm').submit()">Log out</a>
</form>
</text>
} else {
<ul>
<!--li><a href="~/Account/Register">Register</a></li-->
<li><a href="~/Account/Login">Log in</a></li>
</ul>
}
第二种形式
<form action ="" id="query" method="post"> <!--need to search database for a match of medirecord, form is used here-->
<div data-role="fieldcontain">
<label for="name">Patient NRIC: </label>
<input type="text" name="nric" id="nric" value="" />
</div>
<input value="Search" type="submit" data-role="button" data-theme="b" /><!--if cannot find display error msg else go to patient_hist.cshtml-->
</form>
IsPost 事件
if(IsPost)
{
String Nric = Request.Form["nric"];
//var db = Database.Open("StarterSite");
//var user = db.QuerySingle("SELECT * FROM Patient WHERE NRIC = @0", Nric);
var user = "test";
user = null;
if(user != null)
{
<script type="text/javascript">
alert("Not a user!");
</script>
}
else
{
<script type="text/javascript">
alert("Its a user!");
</script>
}
}
else
{
<script type="text/javascript">
alert("Not a Post");
</script>
}
如果我要取出其他,单击第二种形式的按钮后,表单将刷新而没有任何反应