Instead of that you can try the following,
Give CssClass="btnSubmit" to your Button and write the following in script tag into head part
$(document).ready(function () {
$(".btnSubmit").click(function () {
$('#dvLoader').show();
if ($("#aspnetForm").valid()) {
return true;
}
else {
$('#dvLoader').hide();
return false;
}
});
});
and the code of
having id dvLoader is
<div id="dvLoader" style="display: none;">
<div id="updateProgressBackgroundFilter" style="background-color: Gray;<br mode=" hold=" /> filter: alpha(opacity=80); opacity: 0.80; width: 100%; top: 0px; left: 0px; position: fixed;<br mode=">
</div>
<div class="centered" style="font-family: Trebuchet MS;<br mode=" hold=" /> filter: alpha(opacity=100); opacity: 1; font-size: small; position: absolute;<br mode=">
<img alt="Loading" src="../Images/ajax_loader.gif" height="150" width="150" />
</div>
</div>
Here put your loading image instead of "../Images/ajax_loader.gif". if you want your image in center add this css in header part.
<style type="text/css">
.centered
{
position: fixed;
top: 50%;
left: 50%;
margin-top: -75px;
margin-left: -75px;
}
</style>
I have already added this class to the div.
I hope this will work fine for you.