我想知道是否可以使用单独的标签页模型填充标签页?
我有两个带有两个单独模型的标签。标签2的字段需要标签1的信息。这可能吗?
标签示例:
tabstrip.Add().Text("Pre-screening")
.Selected(true)
.Enabled(true)
.Content(Html.Partial("~/Views/EyeTestReport/_Prescreening.cshtml", new Website.Models.EyeTestReport.PreScreeningViewModel(Model.VisitID)).ToHtmlString());
tabstrip.Add().Text("Screening")
.Enabled(true)
.Content(Html.Partial("~/Views/EyeTestReport/_Screening.cshtml", new Website.Models.EyeTestReport.ScreeningViewModel(Model.VisitID)).ToHtmlString());
在选项卡1中使用模型填充的字段:
<div style="margin-right:10px; padding-top:10px;" class="form-field">
@Html.Kendo().NumericTextBoxFor(model => model.VAL).Format("{0:n2}").HtmlAttributes(new { @class = "k-textboxC reset", id = "LeftVA" })
</div>
在选项卡2中需要填充的字段
<div style="margin-right:10px; padding-top:10px;" class="form-field">
@(Html.Kendo().TextBox().Name("LeftVA").Value("").HtmlAttributes(new { @class = "k-textboxC ", @readonly = "readonly" }))
</div>
谢谢。
答案 0 :(得分:0)
我决定将第一个标签视图模型简单地嵌套到第二个标签视图模型中,然后像这样显式调用它:
public class ScreeningViewModel
{
public AutoRefracViewModel AutoRefractionDataModel { get; set; }
public PupillaryDistanceViewModel PupillaryDistanceDataModel { get; set; }
public IopViewModel IOPDataModel { get; set; }
public HabitualRxViewModel HabitualRxViewModel { get; set; }
public PreScreeningViewModel PreScreeningViewModel { get; set; }
public long VisitID { get; set; }
public ScreeningViewModel(long ID)
{
PreScreeningViewModel = new PreScreeningViewModel(ID); //first tab model
AutoRefractionDataModel = new AutoRefracViewModel(ID);
PupillaryDistanceDataModel = new PupillaryDistanceViewModel(ID);
IOPDataModel = new IopViewModel(ID);
HabitualRxViewModel = new HabitualRxViewModel(ID);
}
}
然后在视图上这样称呼它:
<div style="margin-right:10px; padding-top:10px;" class="form-field">
@(Html.Kendo().TextBoxFor(m => m.PreScreeningViewModel.VAL).HtmlAttributes(new { @class = "k-textboxC ", @readonly = "readonly" }))
</div>