Hi All,
I have been looking for a method in ASP.NET to be able to reuse mark-up from within a page file in the same page file.
Most of the time we have mark up that is used over and over within a page, but it is not re-useable in any other page.
For example the following asp markup is created 5 time in an apsx page.
<asp:gridview id="_view5" runat="server" autogeneratecolumns="false" showheader="false" width="100%" xmlns:asp="#unknown">
GridLines="None" onrowdatabound="RowDataBound"
DataSource='<%# ProjectValues( (EntityBase)Eval("Project"), "Health, P16") %>'>
<columns>
<asp:boundfield runat="server" datafield="Caption" itemstyle-cssclass="label" itemstyle-width="50%" />
<asp:boundfield runat="server" datafield="DisplayValue" itemstyle-cssclass="controlcell" />
</columns>
</asp:gridview>
I am looking for something simular to XSL templates where you only place the markup language in a single place and can be called more than once by only providing the name of the template and a number of parameters.
Almost like doing a function call.
For example in XSL you write a template once:
<xsl:template name="table">
<xsl:param name="value" />
<table>
<tr>
<td><xsl:value-of select="$value"/></td>
</tr>
<tr>
<td>
<xsl:value-of select="$value"/>
</td>
</tr>
</table>
</xsl:template>
and then the template can be called multiple times, like in the following example:
<xsl:call-template name="table">
<xsl:with-param name="value" select="'test1'" />
</xsl:call-template>
<xsl:call-template name="table">
<xsl:with-param name="value" select="'test2'" />
</xsl:call-template>
Any help would be appreciated.