如何构建一个使用标签而不是属性来设置属性的UserControl ?



我在一个报告中有几个标记部分,看起来像这样:

<div class="report-section span-24 last">
    <h3 class="section-header">
        Municipal Valuation</h3>
    <p class="section-desc">
        <img src='<%= ResolveUrl("~/Images/info-icon.png")%>' class="left" alt="Section Description" />
        The <strong>Municipal Valuation</strong> is the valuation provided by the relevant
        municipality and represents the market value assessed for rates purposes as at the
        date of valuation.</p>
</div>

我想创建一个用户控件来封装每个节中相同的内容,这样我就可以像这样定义我的节:

<lsReport:Section ID="reportDetails" runat="server" Title="Transfer Information">
    <Description>The <strong>Municipal Valuation</strong> is the valuation provided by the relevant
    municipality and represents the market value assessed for rates purposes as at the
    date of valuation.</Description>
</lsReport:Section>

所以标题总是在<h3 class="section-header">中,描述段落总是有图像,等等。我该怎么做呢?我已经可以在控件的属性中定义Description文本,但是有些描述很长,并且包含标记。我想知道如何使用控件元素的Description子元素设置控件的Description属性。

我认为你可以用一个自定义模板化的用户控件来完成你想要做的事情。

<uc:lstReport id="report1" Title="somevalue" runat="server">    
      <Description>    
           Some custom content you want rendered in the desc.    
      </Description>    
      <ItemTemplate>    
           Here is a calendar: <asp:calendar id="cal1" runat="server" />    
      </ItemTemplate>    
   </uc:lstReport>

查看这个链接。

最新更新