需要在点击链接按钮时显示MODALPOPUP Extender,在模式弹出扩展程序中,我们需要向所需的邮件ID持有者发送电子邮件。
在ASP.NET中使用C#是否有任何规范和功能。请给我最好的建议。
提前致谢
答案 0 :(得分:0)
首先在aspx页面后面的代码中添加下面提到的命名空间,然后从中发送邮件。
using System.Net.Mail;
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To.Add("Email ID where email is to be send");
mail.To.Add("Another Email ID where you wanna send same email");
mail.From = new MailAddress("YourGmailID@gmail.com");
mail.Subject = "Email using Gmail";
string Body = "Hi, this mail is to test sending mail"+
"using Gmail in ASP.NET";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("YourUserName@gmail.com","YourGmailPassword");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}
要发送邮件,请尝试使用C#
中的上述代码点击按钮
打开Modalpopup扩展器<div id="hiddenDiv" style="display:none; visibility:hidden;">
<asp:Button runat="server" ID="hiddenButton" />
/div>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderID" runat="server"
BehaviorID="ModalPopupBehaviorID"
TargetControlID="hiddenButton"
PopupControlID="ModalContainer"
/>
...
//Javascript
var modalPopupBehaviorCtrl = $find('ModalPopupBehaviorID');
modalPopupBehaviorCtrl.show();