开发者

View-Model wiring up difficulties

So I have fields on my view wired up to my base model class like so:

<%= Html.TextBox("FixedRateOverride", Model.FixedRateOverride.HasValue ? Model.FixedRateOverride.Value.ToString(Chatham.Web.Data.Constants.Format.FiveDecimalPlacesFormatString) : "", new { @class = "economicTextBox", propertyName = "FixedRateOverride", onchange = "UpdateField(this);" })%>

What we want to do is now eliminate all of these override type fields that are stored on the model base, and wire them directly up to the actual fields on the class that inherits from this model base (there's 3 types).

The view can't inherit from any single one of them, because coming into the view, it could be any of the 3, so it has to inherit from the base cl开发者_StackOverflow中文版ass.

How would I wire these fields up to the fields of the specific type of model it is when the view only inherits from the base?


I found one way to do it, but I doubt it's the most efficient or recommended way, although it might be. I change the call to the Model in the embedded controls to just casting it as the sub-model like so:

((SubModel)Model)

Seems to work, but like I said, looks weird, and there is probably a better way to do it, but this is my work around for now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜