Righty. Bit of a tricky problem I've gotten myself into.
I've designed an application in such a manner, but I don't think ASP.NET will inherently let me do things this way.

I have a search page - search.aspx.
Now, there are about 10 different searches people can do. I cannot go into the specifics I'm afraid, but each of the searches are totally different requiring differently formatted results etc.
Each search type would also be pulling different data from the DB.

So. My idea was that the search.aspx page, depending on the search being performed, would pull a HTML template file from the drive (which contains <%# %> data tags), pop those into the repeater control and away we go. But alas, when I grab the HTML file from the drive and put it into the repeater, the ASP.Net tags are not evaluated - but instead sent straight as HTML.

So, if I look at the HTML source code of the page, its full of <% Container.DataItem(4) %> etc.


This is the search.aspx designed mode code:
VB Code:
  1. <%@ Page Language="vb" AutoEventWireup="false" Codebehind="search.aspx.vb" Inherits="xxxxxxx.search" %>
  2. <%= strOptionalStartCommentBlock %>
  3. <%= strBodyHeader %>
  4. <asp:Repeater id="Repeater1" runat="server">
  5.     <HeaderTemplate>
  6.         <%= strHeaderTemplate          %>
  7.     </HeaderTemplate>
  8.     <ItemTemplate>
  9.         <%= strItemTemplate            %>
  10.     </ItemTemplate>
  11.     <SeparatorTemplate>
  12.         <%= strSeparatorTemplate       %>
  13.     </SeparatorTemplate>
  14.     <AlternatingItemTemplate>
  15.         <%= strAlternatingItemTemplate %>
  16.     </AlternatingItemTemplate>
  17.     <FooterTemplate>
  18.         <%= strFooterTemplate          %>
  19.     </FooterTemplate>
  20. </asp:Repeater>
  21. <%= strBodyFooter %>
  22. <%= strOptionalEndCommentBlock %>
  23. <%= strOptionalGenerciBody %>

Then in search.aspx I have:

VB Code:
  1. '' part of declarations:
  2.     ''
  3.     Public strBodyHeader As String = vbNullString
  4.     Public strHeaderTemplate As String = vbNullString
  5.     Public strItemTemplate As String = vbNullString
  6.     Public strSeparatorTemplate As String = vbNullString
  7.     Public strAlternatingItemTemplate As String = vbNullString
  8.     Public strFooterTemplate As String = vbNullString
  9.  
  10.     Public strBodyFooter As String = vbNullString
  11.     Public strOptionalStartCommentBlock As String = vbNullString
  12.     Public strOptionalEndCommentBlock As String = vbNullString
  13.     Public strOptionalGenerciBody As String = vbNullString
  14.  
  15.     '' elsewhere:
  16.     ''
  17.         strSQLStatement = "EXECUTE "
  18.  
  19.         strBodyHeader = strFileContent(intQueryType).strBodyHead
  20.         strHeaderTemplate = strFileContent(intQueryType).strRepeaterHeader
  21.         strItemTemplate = strFileContent(intQueryType).strRepeaterItemTemplate
  22.         strAlternatingItemTemplate = strFileContent(intQueryType).strRepeaterAlternateItemTemplate
  23.         strSeparatorTemplate = strFileContent(intQueryType).strRepeaterSeperator
  24.         strFooterTemplate = strFileContent(intQueryType).strRepeaterFooter
  25.         strBodyFooter = strFileContent(intQueryType).strBodyFooter
  26.  
  27.         Select Case intQueryType
  28.             Case 0
  29.                 strSQLStatement &= "SQLFindX "
  30.             Case 1
  31.                 strSQLStatement &= "SQLFindY "
  32.             Case 2
  33.                 strSQLStatement &= "SQLFindZ "
  34.             Case 3
  35.                 strSQLStatement &= "SQLFindA "
  36.             Case 4
  37.                 strSQLStatement &= "SQLFindB "
  38.             Case 5
  39.                 strSQLStatement &= "SQLFindC "
  40.             Case Else
  41.                 GoTo sendGeneric
  42.         End Select
  43.  
  44.         strSQLStatement &= intArea
  45.  
  46.         If Not mySQLConnection.State = ConnectionState.Open Then mySQLConnection.Open()
  47.  
  48.         mySQLCommand = New SqlCommand(strSQLStatement, mySQLConnection)
  49.         mySQLReader = mySQLCommand.ExecuteReader()
  50.         Repeater1.DataSource = mySQLReader
  51.         Repeater1.DataBind()

Here's a snippet from one of the HTML template pages:
(this would be stored in strFileContent(intQueryType))

Code:
						<table width="100%" border="0" ID="Table5">
							<tr>
								<td class="fSmall" vAlign="top" align="left"><b>
								Found <%# = strMatchesUpperBound %> Matches</b><br>
								Displaying matches <%# = strMatchesLowerBound %> to <%# = strMatchesCurrentUpperBound %> below<br>
								&nbsp;<table width="96%" border="0" ID="Table6">
									<tr>
										<td class="fsmall">Searching for<b> 
										<%# strSearchType %> </b> <%# = strLocation %></td>
										<td class="fsmall" align="right">
										<font color="#006699">More Search Options <b>»</b></font> </td>
									</tr>
									<tr>
So you see the ASP.NET Tags in there? When I test the page, the HTML is sent straight to my browser without being evaluated. So. Can I manually tell ASP.NET to re-evaluate a piece of text for ASP.NET server tags?


Or, is there an easier way to have a single asp.net page with different front-ends.
One idea I'm toying with is simply to have 10 different repeater controls on the page, each with their HTML filled in as usual.
Then, depending on the search being performed, I enable the required one, and databind that.
I think that might be easier in the long run....