Advertisement

03.05.2008 at 05:36PM PST, ID: 23218192
[x]
Attachment Details

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

Asked by Oxfam_Australia in Programming for ASP.NET

Tags: VB.NET

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">
    <HeaderTemplate>
        <ol>
    </HeaderTemplate>
    <ItemTemplate>
            <li>
                <a href="#<%# Eval("strIndex") %>"><%# Eval("strQuestion") %></a>
                <asp:PlaceHolder ID="phAnswer<%# Eval("strIndex") %>" runat="server"><%# Eval("strAnswer") %></asp:PlaceHolder>
            </li>
    </ItemTemplate>
    <FooterTemplate>
        </ol>
    </FooterTemplate>
</asp:Repeater>

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.Start Free Trial
 
 
Loading Advertisement...
 
[+][-]03.05.2008 at 07:25PM PST, ID: 21057068

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for ASP.NET
Tags: VB.NET
Sign Up Now!
Solution Provided By: ZachSmith
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.07.2008 at 05:50AM PST, ID: 21069892

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.16.2008 at 06:48PM PDT, ID: 21139409

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628