Can someone please tell me the code I need, so that this form updates the database without needing a refresh?
@{
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>
What I have written kind of works, but I have to hit F5 for it to update, and it's just not what I want. I want to use jQuery/ajax, but I just don't know the code.