Link to home
Start Free TrialLog in
Avatar of Oxfam_Australia

asked on

Parser Error - The server tag is not well formed - oh but it IS!

Hi folks

I'm building an FAQ page where the answers to questions are displayed when the question is clicked on.  I've got a repeater on the page like so:

<asp:Repeater ID="rptFAQ" runat="server">
                <a href="#<%# Eval("strIndex") %>"><%# Eval("strQuestion") %></a>
                <asp:PlaceHolder ID="phAnswer<%# Eval("strIndex") %>" runat="server"><%# Eval("strAnswer") %></asp:PlaceHolder>

But alas, on the PlaceHolder line I receive the following error:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The server tag is not well formed.

Source Error:

Line 13:                             <li>
Line 14:                                 <a href="#<%# Eval("strIndex") %>"><%# Eval("strQuestion") %></a>
Line 15:                                 <asp:PlaceHolder ID="phAnswer<%# Eval("strIndex") %>" runat="server"><%# Eval("strAnswer") %></asp:PlaceHolder>
Line 16:                             </li>
Line 17:                     </ItemTemplate>

The variable strIndex is simply a integer converted to a string.  It works happily in the href, but doesn't like forming part of the ID in the PlaceHolder.  The same thing happens if I use a div with the runat="server" attribute (but it doesn't error if I remove runat="server").

I've seen some suggestions that this may be fixed by using single or no quotes around the ID (i.e. ID='<%# "phAnswer" + Eval("strIndex") %>' ), but that gives me a different error.  As follows:

Parser Error Message: The ID property of a control can only be set using the ID attribute in the tag and a simple value. Example: <asp:Button runat="server" id="Button1" />

Anyway, I was hoping that I could built the FAQ page to cater for users with scripting turned off (hence my wish to include runat="server" tag).  Does anyone have any ideas?  This is really annoying me.
Avatar of ZachSmith
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did you get this figured out?
Avatar of Oxfam_Australia


Sorry I took so long Zach, but I've been working on something else for a couple of weeks.  Anyway, thanks for your response, but alas, it was the answer I didn't really want to hear.  Back to the drawing board I suppose.