不能在剃须刀中识别HTML类吗?

时间:2018-12-19 16:13:34

标签: c# html css razor

因此,我正在设计一个网页,该网页需要用户输入,将其转换为电子邮件正文,然后将所述电子邮件发送到我的电子邮件帐户。我正在遵循Microsoft的本指南:https://code.msdn.microsoft.com/Send-an-email-using-aspnet-80195a1f

它使用@using (Html.BeginForm("email", "Home", FormMethod.Post))调用ActionResult方法,并在Html.BeginForm的括号内使用html表单。这对我来说很有意义-直到我启动页面才看到表单中的每个类由于某种原因已被CSS页面完全忽略。我将表格复制/粘贴到Html.BeginForm括号和ta之外!我的CSS又在那里。我已经阅读了几本关于我要在这里做的事情的教程/帖子,听起来好像没有其他人真的有这个问题...有什么想法吗?

供参考,我的html页面是:

    @model CuttingEdgeWebsite2._0.Models.ServiceRequest

@using (Html.BeginForm("Email", "ServiceRequestsController", FormMethod.Post))
{
    <div class="servicesReq">
        <form class="serviceReqForm" action="mailto:carl@cuttingedgelighting.com?Subject=Service%20Request" method="post" enctype="text/plain">
            <div class="col-left">
                <label>
                    <span class="required">* </span><span>Name:</span><br />
                    <input class="input" type="text" name="ServiceRequestName" required />
                </label><br />
                <label>
                    <span class="required">* </span><span>Email:</span><br />
                    <input class="input" type="text" name="ServiceRequestEmail" required />
                </label><br />
                <label>
                    <span>Company:</span><br />
                    <input class="input" type="text" name="ServiceRequestCompany" />
                </label><br />
                <label>
                    <span>Address:</span><br />
                    <input class="input" type="text" name="ServiceRequestAddress" />
                </label><br /><br />
            </div>
            <div class="serviceTypeGrid">
                <span class="required">* </span><span>Please choose what type of servicing you require:</span><br /><br />
            </div>
            <div class="col-left2">
                <label class="serviceType">
                    <input type="radio" name="serviceType" value="Electrical" /> Electrical<br />
                    <input type="radio" name="serviceType" value="Lighting" /> Lighting<br />
                    <input type="radio" name="serviceType" value="Energy" /> Energy<br />
                    <input type="radio" name="serviceType" value="Multiple" /> Multiple<br />
                </label><br /><br />
            </div>
            <div class="col-right">
                <label>
                    <span>City:</span><br />
                    <input class="input" type="text" name="ServiceRequestCity" />
                </label><br />
                <label>
                    <span>State:</span><br />
                    <input class="input" type="text" name="ServiceRequestState" />
                </label><br />
                <label>
                    <span>Zip Code:</span><br />
                    <input class="input" type="text" name="ServiceRequestZip" />
                </label><br />
                <label>
                    <span class="required">* </span><span>Phone Number:</span><br />
                    <input class="input" type="text" name="ServiceRequestNumber" />
                </label><br />
            </div>
            <label class="commentText">
                <span>Comments:</span><br />
                <textarea name="comments"></textarea><br />
            </label>
            <div class="formSubmitButton">
                <input type="submit" value="Submit" /><br />
                <br />
            </div>
        </form>
    </div>
}

1 个答案:

答案 0 :(得分:1)

我现在不能确定,但​​是我认为该错误以及您正在彼此之间创建,Html.BeginForm命令会创建一个表单。

<div class="servicesReq">
@using (Html.BeginForm("Email", "ServiceRequestsController", FormMethod.Post, new { @class = "serviceReqForm" }))
{   <div class="col-left">
    <label>
        <span class="required">* </span><span>Name:</span><br />
        <input class="input" type="text" name="ServiceRequestName" required />
    </label><br />
    <label>
        <span class="required">* </span><span>Email:</span><br />
        <input class="input" type="text" name="ServiceRequestEmail" required />
    </label><br />
    <label>
        <span>Company:</span><br />
        <input class="input" type="text" name="ServiceRequestCompany" />
    </label><br />
    <label>
        <span>Address:</span><br />
        <input class="input" type="text" name="ServiceRequestAddress" />
    </label><br /><br />
</div>
    <div class="serviceTypeGrid">
        <span class="required">* </span><span>Please choose what type of servicing you require:</span><br /><br />
    </div>
    <div class="col-left2">
        <label class="serviceType">
            <input type="radio" name="serviceType" value="Electrical" /> Electrical<br />
            <input type="radio" name="serviceType" value="Lighting" /> Lighting<br />
            <input type="radio" name="serviceType" value="Energy" /> Energy<br />
            <input type="radio" name="serviceType" value="Multiple" /> Multiple<br />
        </label><br /><br />
    </div>
    <div class="col-right">
        <label>
            <span>City:</span><br />
            <input class="input" type="text" name="ServiceRequestCity" />
        </label><br />
        <label>
            <span>State:</span><br />
            <input class="input" type="text" name="ServiceRequestState" />
        </label><br />
        <label>
            <span>Zip Code:</span><br />
            <input class="input" type="text" name="ServiceRequestZip" />
        </label><br />
        <label>
            <span class="required">* </span><span>Phone Number:</span><br />
            <input class="input" type="text" name="ServiceRequestNumber" />
        </label><br />
    </div>
    <label class="commentText">
        <span>Comments:</span><br />
        <textarea name="comments"></textarea><br />
    </label>
    <div class="formSubmitButton">
        <input type="submit" value="Submit" /><br />
        <br />
    </div>
}