将页面上的元素更改为用户控件
因此,我想将页面上的不同 table 和 div 元素更改为用户控件,这样我就可以将它们呈现为部分视图,而不是拥有极其混乱的前端。
一个例子是这个表:
<table id="summaryInformation" class="resultsGrid" cellpadding="2" cellspacing="0">
<tr>
<td id="EffectiveDateLabel" class="resultsCell">
<%= Html.LabelFor(m => m.EffectiveDate) %>
</td>
<td id="EffectiveDateValue" class="alignRight">
<%= Model.EffectiveDate.Value.ToString(Chatham.Web.Data.Constants.Format.DateFormatString) %>
</td>
<td id ="NotionalLabel" class="resultsCell">
<%= Html.LabelFor(m => m.Notional) %>
</td>
<td id="NotionalValue" class="alignRight">
<span>
<%= Chatham.Enumerations.CurrencyHelper.GetFriendlyName((Chatham.Enumerations.Currency)Model.FloatingComponent.CurrencyID.Value) %>
</span>
<%= Model.Notional.Value.ToString(Chatham.Web.Data.Constants.Format.CurrencyCentsIncludedFormatString) %>
</td>
</tr>
<tr>
<td id="MaturityDateLabel" class="resultsCell">
<%= Html.LabelFor(m => m.MaturityDate) %>
</td>
<td id="MaturityDateValue" class="alignRight">
<%= Model.MaturityDate.Value.ToString(Chatham.Web.Data.Constants.Format.DateFormatString)%>
-
<%= Model.AmortizationComponent.MaturityBusinessDayConvention%>
</td>
<td id="Td3" class="resultsCell"> Holiday City</td>
<td id="ddlHolidayCity" colspan="3">
<%for(int i = 0; i < Model.Trx.TransactionHolidayCityCollection.Count; i++){%><%=i > 0 ? "," : ""%>
<%=DropDownData.HolidayDays().ToList().Find(item => item.Value == Model.Trx.TransactionHolidayCityCollection[i].HolidayCityID.Value.ToString()).Text%><%}
%>
</td>
<td>
</tr>
<tr >
<td id="TimeStampLabel" class="resultsCell">
Rate Time Stamp
</td>
<td id="Timestamp" class="alignRight">
<%= Model.StateBag.CurveDate.TimeStamp.ToString(Chatham.Web.Data.Constants.Format.DateTimeFormatString) %>
</td>
</tr>
</table>
我如何将其更改为用户控件,然后如何将其呈现为前端的部分视图?
谢谢!
So I want to change the different table and div elements on my page to be user controls so I can then render them as a partial view instead of having an extremely cluttered front end.
One example would be this table:
<table id="summaryInformation" class="resultsGrid" cellpadding="2" cellspacing="0">
<tr>
<td id="EffectiveDateLabel" class="resultsCell">
<%= Html.LabelFor(m => m.EffectiveDate) %>
</td>
<td id="EffectiveDateValue" class="alignRight">
<%= Model.EffectiveDate.Value.ToString(Chatham.Web.Data.Constants.Format.DateFormatString) %>
</td>
<td id ="NotionalLabel" class="resultsCell">
<%= Html.LabelFor(m => m.Notional) %>
</td>
<td id="NotionalValue" class="alignRight">
<span>
<%= Chatham.Enumerations.CurrencyHelper.GetFriendlyName((Chatham.Enumerations.Currency)Model.FloatingComponent.CurrencyID.Value) %>
</span>
<%= Model.Notional.Value.ToString(Chatham.Web.Data.Constants.Format.CurrencyCentsIncludedFormatString) %>
</td>
</tr>
<tr>
<td id="MaturityDateLabel" class="resultsCell">
<%= Html.LabelFor(m => m.MaturityDate) %>
</td>
<td id="MaturityDateValue" class="alignRight">
<%= Model.MaturityDate.Value.ToString(Chatham.Web.Data.Constants.Format.DateFormatString)%>
-
<%= Model.AmortizationComponent.MaturityBusinessDayConvention%>
</td>
<td id="Td3" class="resultsCell"> Holiday City</td>
<td id="ddlHolidayCity" colspan="3">
<%for(int i = 0; i < Model.Trx.TransactionHolidayCityCollection.Count; i++){%><%=i > 0 ? "," : ""%>
<%=DropDownData.HolidayDays().ToList().Find(item => item.Value == Model.Trx.TransactionHolidayCityCollection[i].HolidayCityID.Value.ToString()).Text%><%}
%>
</td>
<td>
</tr>
<tr >
<td id="TimeStampLabel" class="resultsCell">
Rate Time Stamp
</td>
<td id="Timestamp" class="alignRight">
<%= Model.StateBag.CurveDate.TimeStamp.ToString(Chatham.Web.Data.Constants.Format.DateTimeFormatString) %>
</td>
</tr>
</table>
How would I change this into a user control and then how would I render this as a partial view in the front end?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了。只需将每个
table
元素放入其自己的 .aspx 文件中,在顶部导入相同的文件,然后将它们呈现为部分视图即可。Figured it out. Just took each
table
element and put it into its own .aspx file, importing the same files at the top, and then rendered them as partial views instead.