EmailSender email = new EmailSender {
EmailAdresNaar = "HERE",
Onderwerp = "Test email",
Bericht = "<b>Dit is een test</b>"
+ "<i>cursief kan ook.</i>."
};
email.SendEmail();
如何将字符串放在HERE所在的位置,并在其中添加字符串数据:
<div class="editor-label">
Email
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Klant.email)
@Html.ValidationMessageFor(model => model.Klant.email)
<input type="submit" value="Verstuur" />
</div>
答案 0 :(得分:2)
[HttpPost]
public ActionResult methodName(Class model)
{
EmailSender email = new EmailSender {
EmailAdresNaar = model.Klant.email,
Onderwerp = "Test email",
Bericht = "<b>Dit is een test</b>"
+ "<i>cursief kan ook.</i>."
};
email.SendEmail();
}
你的观点应该是:
@using(Html.BeginForm("methodName"))
{
<div class="editor-label">
Email
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Klant.email)
@Html.ValidationMessageFor(model => model.Klant.email)
<input type="submit" value="Verstuur" />
</div>
}
也许阅读一下MVC的基础知识?
答案 1 :(得分:1)
这样做: 在视图中:
@using (Html.BeginForm("MyMethod", "MyController"))
{
<div class="editor-label">
Email
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Klant.email)
@Html.ValidationMessageFor(model => model.Klant.email)
<input type="submit" value="Verstuur" />
</div>
}
控制器中的
public ActionResult MyMethod(ModelName model)
{
EmailSender email =
new EmailSender {
EmailAdresNaar = model.Klant.email,
Onderwerp = "Test email",
Bericht = "<b>Dit is een test</b> <i>cursief kan ook.</i>."
};
email.SendEmail();
}