问题描述:

I have the following code in a Partial View that is Rendered inside of another Partial View that is used as the _layout for all views in the project. There is a textarea for comments. I need to get the value of the Textarea to the Action Method in my controller. There is no ViewModel, so I don't know how to capture the contents.

 <header>

<h4> Application Notes </h4>

<a href="#" class="icon-print"></a>

@using (@Html.BeginForm("Comment", "LoanApplication"))

{

@Html.TextArea("Comment")

@*<textarea cols="100" rows="2" name="Comment" placeholder="Leave Comment ..."></textarea>*@

<input value="Add Comment" type="submit" />

}

</header>

The controller code is :

[HttpPost]

[Route("Comment")]

public async Task<ActionResult> Comment(string comment)

{

var loanApplicationServiceProxy = base.ServiceProvider.LoanApplicationServiceProxy;

var applicationComment = new LoanApplicationComment

{

};

await loanApplicationServiceProxy.PutLoanApplicationCommentAsync(applicationComment);

return View();

}

It seems as if it should be something easy, but I can't seem to figure it out. Thanks for any and all assistance.

网友答案:

Change

string comment

To

string Comment

One other thing to try is to receive a FormCollection instead.

相关阅读:
Top