0

コメントのテキスト領域に、相談中のプロパティの 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>

それを機能させる方法を知っていますか?

4

1 に答える 1