I want to change my button text dynamically using c# in asp.net. I also tried dynamic javascript alert popup, however it also shows after mail sent.
Currently i have;
protected void btnSend_Click(object sender, EventArgs e)
{
btnSend.Text = "Sending.."; // Changing Button text
ScriptManager.RegisterStartupScript(btnSend,GetType(), "Javascript", "javascript:helloWorld(); ", true); // Also popup javascript test output
using (MailMessage mm = new MailMessage("[email protected]", "[email protected]"))
{
mm.Subject = "Dropped Mails";
string body = Request.Form["email"];
body+="<br>" + "<br>" + Request.Form["message"];
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.office365.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential("[email protected]", "Bensezer10.");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
}
}
and in aspx side;
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<section class="cid-qKKEwJNZ1Q mbr-fullscreen mbr-parallax-background" id="header15-2p">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<table style="width: 100%; text-align: center; margin-top: 0px; height: 78px;">
<tr>
<td style="text-align: center;">
<asp:Button ID="btnSend" runat="server" Text="SEND" Width="200px" BorderStyle="None" Height="60px" Font-Names="SF Pro Display" Font-Size="14pt" CssClass="ButtonClass" OnClick="btnSend_Click" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSend" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</section>
</form>
Well, it changes the buttontext after sending mail function is completed which is 3 second later.
How can i make this dynamically ?
btnSend.Text = "SEND COMPLETE";aftersmtp.Send(mm);?