对齐文本框?并将此表单发送到电子邮件

时间:2013-11-24 03:35:04

标签: html5 asp.net-mvc-4 razor

我试图让联系表单中的文本框对齐。但我不确定该怎么做。我没有任何运气而与css搞砸了。我也一直试图让这个表格发送到电子邮件..没有运气。任何帮助表示赞赏!

Contact.cshtml代码:

    <legend>Registration Form</legend>
        <ol>

            <li>
                @Html.LabelFor(m => m.Reason)
                @Html.TextBoxFor(m => m.Reason)
            </li>
            <li>
                @Html.LabelFor(m => m.FirstName)
                @Html.TextBoxFor(m => m.FirstName, new { placeholder = "John " })
            </li>
            <li>
                @Html.LabelFor(m => m.LastName)
                @Html.TextBoxFor(m => m.LastName, new { placeholder = "Doe" })
            </li>
             <li>
                @Html.LabelFor(m => m.Username)
                @Html.TextBoxFor(m => m.Username, new {placeholder = "JohnDoe01" })
       ...............
    <input type="submit" value="Send" />
</fieldset>

联系模式:

public class ContactModel
{
[Required]
[Display(Name = "Reason for contact")]
   public string Reason { get; set; }

    [Required]
    [Display(Name = "First Name")]
   public string FirstName { get; set; }

    [Required]
    [Display(Name = "Last Name")]
   public string LastName { get; set; }

    [Required]
    [Display(Name = "User Name")]
    public string Username { get; set; ...........}

1 个答案:

答案 0 :(得分:0)

这是一个很好的电子邮件示例的答案。您只需将模型传递回控制器即​​可处理电子邮件的创建/发送。

Send e-mail via SMTP using C#