我有一个以下的视图模型,它将用于获取问题描述和重现问题的步骤。
我希望为用户提供一个简单的控制方式来输入问题重现步骤。因此,我将div元素的contenteditable属性设置为true。
我已将ReCreationSteps绑定到Div元素,但它无法正常工作。一旦表单提交,我就无法在ReCreationSteps属性中获取DIV的值/HTML。
请问是否有人能够帮助我解决这个问题或提供其他解决方案?
public class IssueViewModel
{
public string IssueDesc { get; set; }
public string ReCreationSteps { get; set; }
}
查看
@using (Html.BeginForm())
{
@Html.LabelFor(model => model.IssueDescription)
@Html.TextAreaFor(m=>m.IssueDescription)
@Html.LabelFor(model => model.ReCreationSteps )
<div class="editable" id="ReCreationSteps " name="ReCreationSteps" contenteditable="true">
<ol>
<li></li>
</ol>
</div>
<input value="Create" type="submit" />
}
控制器
[HttpPost]
public ActionResult Create(IssueViewModel model)
{
string html = model.Recreation;
//<ol><li>Step:1 Enter the text</li><li>Step:2 Click the button <li></ol>
Issue newIssue = model.ToIssue(); // here value will be splitted and add steps to table
_issueRepository.AddIssue(Issue);
}
我希望为用户提供一个简单的控制方式来输入问题重现步骤。因此,我将div元素的contenteditable属性设置为true。
我已将ReCreationSteps绑定到Div元素,但它无法正常工作。一旦表单提交,我就无法在ReCreationSteps属性中获取DIV的值/HTML。
请问是否有人能够帮助我解决这个问题或提供其他解决方案?
<input>
类型没有在 div 内部,是在其他地方动态创建的吗?能否详细说明一下如何填充 div 内部的任何<input>
元素?目前,我对你的过程理解有很大的空白。 - jim tollan