render jquery script, update mail model
This commit is contained in:
parent
2e11f16369
commit
02c2d8b519
@ -13,18 +13,23 @@ namespace MailSender.Models
|
|||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
//[ForeignKey]
|
//[ForeignKey]
|
||||||
//public int UserId //id usera ktory wyslal maila
|
//public int UserId //id usera ktory wyslal maila
|
||||||
|
|
||||||
[Display(Name = "Subject")]
|
[Display(Name = "Subject")]
|
||||||
[Required]
|
[Required(AllowEmptyStrings = false)]
|
||||||
public string Subject { get; set; }
|
public string Subject { get; set; }
|
||||||
[EmailAddress]
|
|
||||||
[Required]
|
[DataType(DataType.EmailAddress)]
|
||||||
|
[Required(AllowEmptyStrings = false, ErrorMessage = "You need to type in an e-mail")]
|
||||||
|
[RegularExpression(".*@.*\\..*", ErrorMessage = "You typed in e-mail in wrong format")]
|
||||||
[Display(Name = "E-Mail to")]
|
[Display(Name = "E-Mail to")]
|
||||||
public string EMailTo { get; set; }
|
public string EMailTo { get; set; }
|
||||||
|
|
||||||
[Required(AllowEmptyStrings = false, ErrorMessage = "You need to type in a message to send")]
|
[Required(AllowEmptyStrings = false, ErrorMessage = "You need to type in a message to send")]
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[StringLength(500, ErrorMessage = "Message can be at most 500 characters long")]
|
[StringLength(500, ErrorMessage = "Message has to have between 1 and 500 chars", MinimumLength = 1)]
|
||||||
public string Content { get; set; }
|
public string Content { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,26 +4,34 @@
|
|||||||
}
|
}
|
||||||
<h2>Send Mail</h2>
|
<h2>Send Mail</h2>
|
||||||
|
|
||||||
@if(ViewData.ContainsKey("mailErr")){
|
@if (ViewData.ContainsKey("mailErr"))
|
||||||
<h3>Error: @ViewData["mailErr"]</h3>
|
{
|
||||||
}
|
<h3>Error: @ViewData["mailErr"]</h3>
|
||||||
|
}
|
||||||
|
|
||||||
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
|
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
|
||||||
{
|
{
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@Html.LabelFor(i => i.Subject, new { @class = "label-form" })
|
@Html.LabelFor(i => i.Subject, new { @class = "label-form" })
|
||||||
@Html.EditorFor(i => i.Subject, new { htmlAttributes = new { @class = "form-control", @placeholder = "Subject" } })
|
@Html.EditorFor(i => i.Subject, new { htmlAttributes = new { @class = "form-control", @placeholder = "Subject" } })
|
||||||
|
@Html.ValidationMessageFor(i => i.Subject)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@Html.LabelFor(i => i.EMailTo, new { @class = "label-form" })
|
@Html.LabelFor(i => i.EMailTo, new { @class = "label-form" })
|
||||||
@Html.EditorFor(i => i.EMailTo, new { htmlAttributes = new { @class = "form-control", @placeholder = "To" } })
|
@Html.EditorFor(i => i.EMailTo, new { htmlAttributes = new { @class = "form-control", @placeholder = "To" } })
|
||||||
|
@Html.ValidationMessageFor(i => i.EMailTo)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@Html.LabelFor(i => i.Content, new { @class = "label-form" })
|
@Html.LabelFor(i => i.Content, new { @class = "label-form" })
|
||||||
@Html.EditorFor(i => i.Content, new { htmlAttributes = new { @class = "form-control", @placeholder = "Body" } })
|
@Html.EditorFor(i => i.Content, new { htmlAttributes = new { @class = "form-control", @placeholder = "Body" } })
|
||||||
|
@Html.ValidationMessageFor(i => i.Content)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="submit" value="Send" />
|
<input type="submit" value="Send" />
|
||||||
|
}
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
@Scripts.Render("~/bundles/jqueryval")
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user