gpt4 book ai didi

c# - Razor 无法识别 Html 类?

转载 作者:太空宇宙 更新时间:2023-11-04 06:40:19 24 4
gpt4 key购买 nike

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

它使用 @using (Html.BeginForm("email", "Home", FormMethod.Post)) 调用 ActionResult 方法,并将 html 表单本身放在 Html 的括号内。开始表格。这对我来说很有意义 - 直到我启动我的页面才看到我表单中的每个类由于某种原因都被 css 页面完全忽略了。我在 Html.BeginForm 括号外复制/粘贴了表单,然后 ta da!我的 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>
}

最佳答案

我现在不能确定,但​​我相信错误和你在另一个中创建一个,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>
}

关于c# - Razor 无法识别 Html 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53855142/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com