...

View Full Version : The server tag is not well formed.



binici
05-15-2007, 07:51 PM
I have a DataList and assigning the objects accordingly. I am also using the Event ItemDataBound to hide/show a control if there is data. Not sure why I am receiving this error?

ASPX:

<body topmargin="0" leftmargin="10" rightmargin="10" bgcolor="ffffff">

<table width="335" cellSpacing="0" cellPadding="0" border="0">

<tr>

<td align="left">


<asp:DataList ID="QuickLinkItems" runat="server" BorderWidth="0px" CellPadding="0" DataSourceID="SqlDataSource1">

<ItemTemplate>

<asp:Table ID="table1" runat="server" Width="335" CellPadding="0" CellSpacing="0" BorderWidth="1">

<asp:TableRow>

<asp:TableCell ColumnSpan="2"><a name="<%#Container.DataItem("orderby")%>" id="<%#Container.DataItem("orderby")%>"></a><br><span class="MainHead" title="<%#Container.DataItem("url_text")%>"><%#Container.DataItem("url_text")%></span></asp:TableCell>

</asp:TableRow>

<asp:TableRow>

<asp:TableCell ID="image_cell" runat="server" VerticalAlign="Top">

<a class="HighlightMore" href="#" title="<%#Container.DataItem("url_text")%>" onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><img id="item_image" runat="server" src="/homepage/Images/Thumbs/<%#Container.DataItem("image_name")%>" align="left" hspace="15" vspace="10" alt="<%#Container.DataItem("url_text")%>" border="0"></a>

</asp:TableCell>

<asp:TableCell VerticalAlign="Top" Width="100%"><br />

<%#Container.DataItem("description")%>

<br /><br />

<div align="right"><A class="HighlightMore" href="#" title="<%#Container.DataItem("homepage_link_text")%>" onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><%#Container.DataItem("homepage_link_text")%></a></div>

</asp:TableCell>

</asp:TableRow>

</asp:Table>

</ItemTemplate>

</asp:DataList>


</td>

</tr>

<tr>

<td height="275" colspan="2">&nbsp;

</td>

</tr>

</table>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ connectionStrings:connectionstring %>" ProviderName="System.Data.SqlClient" SelectCommand="SELECT url_text, url, orderby, homepage_link_text, description, image_name FROM tFeedArticles WHERE homepage_link_yn = 1 ORDER BY orderby" SelectCommandType="Text"></asp:SqlDataSource>

</body>

</html>



Codebehind:



Protected Sub QuickLinkItems_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles QuickLinkItems.ItemDataBound

Trace.IsEnabled = True

Trace.Warn("QuickLinkItems items", e.Item.FindControl("image_cell").ID)

Dim TableRow As TableCell = CType(e.Item.FindControl("image_cell"), TableCell)

Dim ItemImage As HtmlImage = CType(e.Item.FindControl("item_image"), HtmlImage)

If ItemImage.Src = "" Then

TableRow.Visible = False

Else

TableRow.Visible = True

End If

Trace.Warn("ItemImage", ItemImage.Src)

End Sub


The error is being thrown here

Line 82: <a class="HighlightMore" href="#" title="<%#Container.DataItem("url_text")%>" onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><img id="item_image" runat="server" src="/homepage/Images/Thumbs/<%#Eval("image_name")%>" align="left" hspace="15" vspace="10" alt="<%#Container.DataItem("url_text")%>" border="0"></a>

I checked my double quotes and tags to make sure they were correct.

nikkiH
05-15-2007, 08:38 PM
I checked my double quotes and tags to make sure they were correct.

Nested quotes. :D

title="<%#Container.DataItem("url_text")%>"

should be
title='<%#Container.DataItem("url_text")%>'

binici
05-15-2007, 09:01 PM
Nested quotes. :D

title="<%#Container.DataItem("url_text")%>"

should be
title='<%#Container.DataItem("url_text")%>'

Thanks for the reply, I changed all the nested quotes with single quotes, but I still recieve the same error.

ASPX:
<asp:DataList ID="QuickLinkItems" runat="server" BorderWidth="0px" CellPadding="0" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Table ID="table1" runat="server" Width="335" CellPadding="0" CellSpacing="0" BorderWidth="1">
<asp:TableRow>
<asp:TableCell ColumnSpan="2"><a name='<%#Container.DataItem("orderby")%>' id="<%#Container.DataItem("orderby")%>'></a><br><span class="MainHead" title='<%#Container.DataItem("url_text")%>'><%#Container.DataItem("url_text")%></span></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="image_cell" runat="server" VerticalAlign="Top">
<a class="HighlightMore" href="#" title='<%#Container.DataItem("url_text")%>' onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><img id="item_image" runat="server" align="left" hspace="15" vspace="10" alt='<%#Container.DataItem("url_text")%>' border="0" src='Images/Thumbs/<%#Container.DataItem("image_name")%>' /></a>
</asp:TableCell>
<asp:TableCell VerticalAlign="Top" Width="100%"><br />
<%#Container.DataItem("description")%>
<br /><br />
<div align="right"><A class="HighlightMore" href="#" title='<%#Container.DataItem("homepage_link_text")%>' onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><%#Container.DataItem("homepage_link_text")%></a></div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
</asp:DataList>


In the source code I tracked it down, looks like something is happening with the img src attribute tag? Doesn't like it?
Source code:

<tr>
<td>
<table id="QuickLinkItems__ctl0_table1" cellspacing="0" cellpadding="0" border="0" style="border-width:1px;border-style:solid;width:335px;border-collapse:collapse;">
<tr>
<td colspan="2"><a name='1' id="1'></a><br><span class="MainHead" title='Final Test!'>Final Test!</span></td>
</tr><tr>
<td id="QuickLinkItems__ctl0_image_cell" valign="top">
<a class="HighlightMore" href="#" title='Final Test!' onclick="window.open('www.pwr.net','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes, resizable=yes,width=795,height=650,top=10,left=40'); return false"><img src="Images/Thumbs/<%#Container.DataItem("image_name")%>" id="QuickLinkItems__ctl0_item_image" align="left" hspace="15" vspace="10" border="0" alt="Final Test!" /></a>
</td><td valign="top" style="width:100%;"><br />
Hello world!
<br /><br />
<div align="right"><A class="HighlightMore" href="#" title='>> Read More' onclick="window.open('www.pwr.net','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes, resizable=yes,width=795,height=650,top=10,left=40'); return false">>> Read More</a></div>
</td>
</tr>
</table>
</td>
</tr>

glenngv
05-15-2007, 09:22 PM
Nested quotes. :D

title="<%#Container.DataItem("url_text")%>"

should be
title='<%#Container.DataItem("url_text")%>'
That's not nested quotes. That's server-side language (VB.NET, I believe) in the title attribute.

binici, what error msg are you getting? Is it a server-side error or client-side error?

binici
05-15-2007, 09:54 PM
That's not nested quotes. That's server-side language (VB.NET, I believe) in the title attribute.

binici, what error msg are you getting? Is it a server-side error or client-side error?

Ok, now I am not receiving an error, but the html is not formatted well.

here is the aspx:

<asp:DataList ID="QuickLinkItems" runat="server" BorderWidth="0px" CellPadding="0" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Table ID="table1" runat="server" Width="335" CellPadding="0" CellSpacing="0" BorderWidth="1">
<asp:TableRow>
<asp:TableCell ColumnSpan="2"><a name='<%#Container.DataItem("orderby")%>' id='<%#Container.DataItem("orderby")%>'></a><br><span class="MainHead" title='<%#Container.DataItem("url_text")%>'><%#Container.DataItem("url_text")%></span></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="image_cell" runat="server" VerticalAlign="Top">
<a class="HighlightMore" href="#" title='<%#Container.DataItem("url_text")%>' onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><img id="item_image" runat="server" align="left" hspace="15" vspace="10" alt='<%#Container.DataItem("url_text")%>' border="0" src='Images/Thumbs/<%#Container.DataItem("image_name")%>' /></a>
</asp:TableCell>
<asp:TableCell VerticalAlign="Top" Width="100%"><br />
<%#Container.DataItem("description")%>
<br /><br />
<div align="right"><A class="HighlightMore" href="#" title='<%#Container.DataItem("homepage_link_text")%>' onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><%#Container.DataItem("homepage_link_text")%></a></div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
</asp:DataList>

When I view the page its screwed up and looks like this:

http://www.pwr.net/homepage/error.jpg

Please help!

nikkiH
05-15-2007, 10:08 PM
Why are you even doing that, by the way?
There are so many controls for this sort of thing. There is rarely a reason to use this syntax. If you're using Container DataItem, you're in a databound control. why not use Repeater / ItemTemplate etc?

For me to make good suggestions to an alternative, I need to know if you're using 1.1 or 2.0. A lot of things changed with 2.0.

binici
05-15-2007, 10:17 PM
Why are you even doing that, by the way?
There are so many controls for this sort of thing. There is rarely a reason to use this syntax. If you're using Container DataItem, you're in a databound control. why not use Repeater / ItemTemplate etc?

For me to make good suggestions to an alternative, I need to know if you're using 1.1 or 2.0. A lot of things changed with 2.0.


I am using 2.0, I thought that the reapter and Datalist are similar?

Anyways, I changed the code using the reapter control and same thing is happening

<asp:Repeater ID="reapter1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Table ID="table1" runat="server" Width="335" CellPadding="0" CellSpacing="0" BorderWidth="1">
<asp:TableRow>
<asp:TableCell ColumnSpan="2"><a name='<%#Container.DataItem("orderby")%>' id='<%#Container.DataItem("orderby")%>'></a><br><span class="MainHead" title='<%#Container.DataItem("url_text")%>'><%#Container.DataItem("url_text")%></span></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="image_cell" runat="server" VerticalAlign="Top">
<a class="HighlightMore" href="#" title='<%#Container.DataItem("url_text")%>' onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><img id="item_image" runat="server" src='Image/Thumbs/<%#Container.DataItem("image_name")%>' align="left" hspace="15" vspace="10" alt='<%#Container.DataItem("url_text")%>' border="0"></a>
</asp:TableCell>
<asp:TableCell VerticalAlign="Top" Width="100%"><br />
<%#Container.DataItem("description")%>
<br /><br />
<div align="right"><A class="HighlightMore" href="#" title='<%#Container.DataItem("homepage_link_text")%>' onclick="window.open('<%#Container.DataItem("url")%>','_PWRUpGuide','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=795, height=650,top=10,left=40'); return false"><%#Container.DataItem("homepage_link_text")%></a></div>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
</asp:Repeater>

Did you take a look at the code source and the screen shot? It's like the

<img id="item_image" runat="server" src='Image/Thumbs/<%#Container.DataItem("image_name")%>' align="left" hspace="15" vspace="10" alt='<%#Container.DataItem("url_text")%>' border="0">

is breaking because of the "/" are used in the src attribute.

Its frustrating

binici
05-15-2007, 10:43 PM
Fixed:

I used the ItemDataBound event and manipulate the img tag with the path name as a string and pull the data from the datasource, which is the image name and write it out! Works like a charm!

Thank you,

Robert



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum