有人可以告诉我我需要的代码,以便此表单无需刷新即可更新数据库?
@{
Layout = "~/_template1.cshtml";
var db = Database.Open("stayinflorida");
var CurrentUser = WebSecurity.CurrentUserId;
var userdetails = ("SELECT * from UserProfile WHERE UserId='8'");
var quserdetails = db.QuerySingle(userdetails, CurrentUser);
if (IsPost){
var updateuserdetails = "UPDATE UserProfile SET FirstName = @0, LastName = @1 WHERE UserID='8'";
db.Execute(updateuserdetails, Request["FirstName"], Request["LastName"]);
}
}
<h1>My Details</h1>
<hr>
<form method="post" action="~/Account/MyDetails.cshtml">
<fieldset>
<label>First Name</label>
<input class="input-xlarge" type="text" name="FirstName" placeholder=".input-xlarge" value="@quserdetails.FirstName">
<br>
<label>Last Name</label>
<input class="input-xlarge" type="text" name="LastName" placeholder=".input-xlarge" value="@quserdetails.LastName">
<button type="submit" class="btn btn-success">Update</button>
<button type="submit" class="btn btn-success">Cancel</button>
</fieldset>
</form>
我写的作品,但我必须按 F5 才能更新,这不是我想要的。我想使用 jQuery/ajax,但我只是不知道代码。