I have a basic test ASP MVC web project that displays a list of 10 names and allows the user to select/edit any name. The project works fine.
My question relates to the edit view after the uses selects 'edit' for one of the listed names. The edit action code is listed below.
How do I change the text of the save button on the edit view to 'Please wait' while the data is posted back. As you can see from the code there is a 3 sec wait to simulate a delay.
here is the snippet of code from the edit.vbhtml code for the edit view.
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
I have tried using onclick but it doesnt fire.
can anybody help please?
Function Edit(ByVal id As Integer) As ActionResult
Dim student As KeithViewModel = New KeithViewModel With {
.Id = id,
.Name = "Name" & id}
Return View(student)
End Function
' POST:
<HttpPost()>
Function Edit(ByVal rec As KeithViewModel) As ActionResult
Try
' TODO: Add update logic here
System.Threading.Thread.Sleep(3000)
Return RedirectToAction("Index")
Catch
Return View()
End Try
End Function
What I have tried:
<button type="submit"
id="submitButton"
class="btn btn-primary"
onclick="return
DisplayProgressMessage(this, 'Saving...');">
Save
</button>
<script>
function DisplayProgressMessage(ctl, msg) {
$(ctl).prop("disabled", true);
$(ctl).text(msg);
return true;
};
</script>