【发布时间】:2013-12-27 05:27:22
【问题描述】:
由于某种原因,我无法让 NancyFx 绑定到我的网页模型。如果这很重要,我会自行托管。
这是我的路线代码:
Get["/fax.html"] = p =>
{
FaxModel model = new FaxModel();
var foundType = processes.Where(proc => proc.GetType().ToString().Contains("FaxServer"));
if(foundType.First() != null)
{
bool enabled = Boolean.Parse(WorkflowSettings.GetValue(foundType.First().GetProcessName(), "Enabled"));
bool deleteAfterSuccess = Boolean.Parse(WorkflowSettings.GetValue(foundType.First().GetProcessName(), "DeleteWorkflowItemsAfterSuccess"));
model.EnableFaxes = enabled;
model.DeleteFaxes = deleteAfterSuccess;
// Bind the data
this.BindTo<FaxModel>(model);
}
return View["fax.html"];
};
这是我的模型:
[Serializable]
public class FaxModel
{
public bool EnableFaxes { get; set; }
public bool DeleteFaxes { get; set; }
}
现在这是我的 HTML 代码:
<div id="body">
<form method="post" action="fax.html" name="fax_settings">
<ul>
<li>
<input name="EnableFaxes" value="true" type="checkbox">Automated Faxing Enabled
</li>
<li>
<div style="margin-left: 80px;"><input name="DeleteFaxes" value="true" type="checkbox">Delete workflow items when fax is successful</div>
</li>
</ul>
<button name="Save">Save</button>
</form>
</div>
我不明白为什么它根本没有填充这些复选框。有人有想法吗?
【问题讨论】: