Monday, June 3, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
108
rated 0 times [  112] [ 4]  / answers: 1 / hits: 28306  / 11 Years ago, tue, july 16, 2013, 12:00:00

What is the best way to show a loader and disable the button when we submit a form:



@using (Ajax.BeginForm(MVC.Account.Login(), new AjaxOptions { OnSuccess = onLoginSuccess }, new { @id = loginForm }))
{
<div id=logbtn>
<input type=submit name=invisible class=subinvisible/>
<p>@HeelpResources.AccountLoginViewLoginButtonLabel</p>
<img src=~/Content/Images/ui-symb-arrow-right-white-15x15.png width=13 height=12 />
</div>
}


The loader image file is



<img src=~/Content/Images/ui-loader-white-16x16.gif />


Maybe using the OnBegin from the BeginForm to show the loader and the OnComplete to hide-it? But how can I change the image?



Any sugestion to find nice quality free loaders?



Thanks


More From » c#

 Answers
21

Put your loading image tag inside a div tag like this:



<div id=loading>
<img src=~/Content/Images/ui-loader-white-16x16.gif />
</div>


In your CSS file:



div#loading { display: none; }


And, in your form:



@using (Ajax.BeginForm(MVC.Account.Login(), 
new AjaxOptions { OnSuccess = onLoginSuccess, LoadingElementId = loading,
OnBegin = onLoginBegin },
new { @id = loginForm }))
{
<div id=logbtn>
<input type=submit name=invisible class=subinvisible/>
<p>@HeelpResources.AccountLoginViewLoginButtonLabel</p>
<img src=~/Content/Images/ui-symb-arrow-right-white-15x15.png width=13 height=12 />
</div>
}


And, add a script to your View:



<script type=text/javascript>
function onLoginBegin()
{
// Disable the button and hide the other image here
// or you can hide the whole div like below
$('#logbtn').hide();
}
</script>

[#76952] Monday, July 15, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
charity

Total Points: 503
Total Questions: 98
Total Answers: 125

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
;