C#을 통해 전자 메일을 보내도록 코드를 추가하고 싶지만 단추가 작동하지 않는 것 같습니다.마스터 페이지가있는 webform에 C# 추가
HTML 코드 : 코드 aspx.cs
<div style="text-align:center">
<p style="background-color: Yellow">if you have a video that you think should be here send it to us</p>Name:
<input type="text" id="Name" />Link:
<input type="text" id="Link" />
<br />Why you think this video should be here:
<br />
<textarea id="Why" rows="5" cols="50"></textarea>
<br />
<input type="submit" id="submit" name="submit" value="Send" style="height: 25px; width: 200px" />
</div>
왜하지만 버튼 아무것도 무슨 일이 생긴하지 누를 때 나도 몰라
public partial class Videos : System.Web.UI.Page
{
public string Answer;
protected void Page_Load(object sender, EventArgs e)
{
Answer = "Email Sent2";
if (Request.Form["submit"] != null)
{
Answer = "Email Sent3";
string Name = Request.Form["Name"];
string Link = Request.Form["Link"];
string Why = Request.Form["Why"];
string body = "<div dir='ltr'>";
body += ("<h4>You got a new video idea from </h4>");
body += (Name);
body += ("<br />");
body += ("Link: " + Link);
body += ("<br />");
body += ("Reason: " + Why);
body += ("</div>");
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("MY EMAIL", "MY PASS"),
EnableSsl = true
};
System.Net.Mail.MailMessage mail1 = new System.Net.Mail.MailMessage();
mail1.Body = body;
mail1.From = new System.Net.Mail.MailAddress("MY EMAIL");
mail1.IsBodyHtml = true;
mail1.Subject = "Vidoe Idea By " + Name;
mail1.To.Add("MY EMAI");
client.Send(mail1);
Answer = "Email Sent";
}
}
. 여기에 무슨 문제가 있습니까?
키보드에 문제가 있습니까? HTML 입력 대신 asp : button 컨트롤을 사용하십시오. – geedubb
먼저 "버튼을 눌러도 아무 것도 안된다"는 사용자 문제가 아니라 프로그래머가 아닌 코드를 디버깅하십시오. 여기 프로그래밍 문제가 있습니다. 둘째, 웹 양식이있는 HTML을 읽을 수 있는지 모르겠지만 를 사용하고 C#에서 txtName.Text 대신이 코드를 읽지 마십시오. ? 따라서 코드를 디버그하고 작동하지 않는 부분을 검색 한 다음 다시 알려주십시오. –
내 코드를 debuged. 그것은 모두 if (Request.Form ..)까지 작동합니다. – KenigOri