将页面上的元素更改为用户控件

发布于 2024-10-16 18:30:55 字数 2992 浏览 4 评论 0原文

因此,我想将页面上的不同 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凡尘雨 2024-10-23 18:30:55

想通了。只需将每个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文