【问题标题】:Error in Contact form联系方式错误
【发布时间】:2015-08-31 06:03:19
【问题描述】:

我需要在评论文本区域中显示关于它正在咨询的属性的 id,我从视图详细信息中获取它,其中有一个按钮“咨询”。

在详细信息视图中:

<a class="btn btn-primary" href="@Url.Action("Contact", "Home", new {PropertyId = @Model.PropertyModel.Property.PropertyId})#consult">
<i class="icon-envelope">
</i>
@Resources.Property.Details.Consulta
</a>

在 HomeController 中:

public ActionResult Contact(string PropertyId)
{
    UserRepository userRepository = new UserRepository();
    User user = userRepository.GetUserByEmail(User.Identity.Name);
    ContactModel model = new ContactModel(user);
    model.Comment = PropertyId;
    return View(model);
}

在 ContactModel 中:

[Required]
[Display(Name = "Comment", ResourceType = typeof(Resources.Entities.Names))]
public string Comment { get; set; }

在 Contact.cshtml 中:

<div class="control-group">
    @Html.LabelFor(m => m.Comment, new { @class = "control-label" })
    <div class="controls">
        @Html.TextAreaFor(m => m.Comment, new {@rows = "6", @style="width:80%;"})
        @Html.ValidationMessageFor(m => m.Comment) 
    </div>
</div>

你知道如何让它工作吗?

【问题讨论】:

  • 使其工作的第一步是了解问题所在。第二步是告诉我们问题是什么,以便我们帮助您完成第一步。

标签: c# asp.net asp.net-mvc contact-form url-action


【解决方案1】:

感谢您的回答!问题是在名为注释的文本区域中没有出现 id 信息(我通过 url 操作提供给控制器)​​。 我看不出我这样做的方式有什么问题。

【讨论】:

    猜你喜欢
    • 2016-04-01
    • 1970-01-01
    • 2012-02-05
    • 1970-01-01
    • 2021-03-16
    • 1970-01-01
    • 1970-01-01
    • 2014-01-09
    • 1970-01-01
    相关资源
    最近更新 更多