Hi RichardSa,
You can't display loading image inside button.
You have to display as modal and change the button text.
Add an gif image.
Create javascript methods to show image.
OnClientClick of button call Show Image javascript method to display image.
HTML
<style type="text/css">
.modal {
position: fixed;
top: 0;
left: 0;
background-color: black;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}
.loading {
font-family: Arial;
font-size: 10pt;
border: 5px solid #67CFF5;
width: 300px;
height: 150px;
display: none;
position: fixed;
background-color: White;
z-index: 999;
}
</style>
<script type="text/javascript">
function disableBtn(btnID, newText) {
var btn = document.getElementById(btnID);
btn.disabled = true;
btn.value = newText;
ShowProgress();
}
function ShowProgress() {
document.getElementsByClassName("loading")[0].style.display = 'block';
}
</script>
<div class="loading" align="center">
Loading. Please wait.<br />
<br />
<img src="loading.gif" alt="" />
</div>
Name:<asp:TextBox runat="server" ID="txtName" /><br />
Last:
<asp:TextBox runat="server" ID="textLast" /><br />
Email:
<asp:TextBox runat="server" ID="textemail" /><br />
Number:
<asp:TextBox runat="server" ID="textNumber" /><br />
<asp:Button ID="btnSubmit" Text="Send" runat="server" OnClick="btnSubmit_Click"
OnClientClick="disableBtn(this.id, 'Sending Email...')" UseSubmitBehavior="false" />
<asp:Label ID="lblMessage" runat="server" /
Namespaces
C#
using System.Configuration;
using System.Net;
using System.Net.Configuration;
using System.Net.Mail;
VB.Net
Imports System.Configuration
Imports System.Net
Imports System.Net.Configuration
Imports System.Net.Mail
Code
C#
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (txtName.Text != "" & textLast.Text != "" & textNumber.Text != "" & textemail.Text != "")
{
SmtpSection smtpSection = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");
using (MailMessage mm = new MailMessage(smtpSection.From, "cletusdestiny33@gmail.com"))
{
mm.Subject = "FOLLOW UP";
mm.Body = "Name: " + txtName.Text + " " + textLast.Text + "<br />Email: " + textemail.Text + "<br />MOBILE NUMBER: " + textNumber.Text;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = smtpSection.Network.Host;
smtp.EnableSsl = smtpSection.Network.EnableSsl;
NetworkCredential networkCred = new NetworkCredential(smtpSection.Network.UserName, smtpSection.Network.Password);
smtp.UseDefaultCredentials = smtpSection.Network.DefaultCredentials;
smtp.Credentials = networkCred;
smtp.Port = smtpSection.Network.Port;
smtp.Send(mm);
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Email send succefully.')", true);
}
}
else
{
lblMessage.Visible = true;
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "*All Fields Are Required*";
}
}
VB.Net
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)
If txtName.Text <> "" And textLast.Text <> "" And textNumber.Text <> "" And textemail.Text <> "" Then
Dim smtpSection As SmtpSection = CType(ConfigurationManager.GetSection("system.net/mailSettings/smtp"), SmtpSection)
Using mm As MailMessage = New MailMessage(smtpSection.From, "cletusdestiny33@gmail.com")
mm.Subject = "FOLLOW UP"
mm.Body = "Name: " & txtName.Text & " " + textLast.Text & "<br />Email: " + textemail.Text & "<br />MOBILE NUMBER: " + textNumber.Text
mm.IsBodyHtml = True
Dim smtp As SmtpClient = New SmtpClient()
smtp.Host = smtpSection.Network.Host
smtp.EnableSsl = smtpSection.Network.EnableSsl
Dim networkCred As NetworkCredential = New NetworkCredential(smtpSection.Network.UserName, smtpSection.Network.Password)
smtp.UseDefaultCredentials = smtpSection.Network.DefaultCredentials
smtp.Credentials = networkCred
smtp.Port = smtpSection.Network.Port
smtp.Send(mm)
ClientScript.RegisterStartupScript(Me.GetType(), "", "alert('Email send succefully.')", True)
End Using
Else
lblMessage.Visible = True
lblMessage.ForeColor = System.Drawing.Color.Red
lblMessage.Text = "*All Fields Are Required*"
End If
End Sub
Screenshot