469,648 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

What Is Going On Here?

I have run into a problem with one of my aspx pages. When I run the
page, I get a "Server Tag Is Not Well Formed" error. This message goes
away when I remove the line with the problem. This simply does not make
any sense. I have triple-checked everything. What am I doing wrong
here?

Below is a snippet of the "problem" line. After that is the entire aspx
page, with the "problem" line marked with HTML comment tags...

<asp:HyperLink id="Test" Target="_blank" Runat="server"
CssClass="One"
NavigateUrl="/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=<%#
DataBinder.Eval(Container.DataItem, "Number") %>"><%#
DataBinder.Eval(Container.DataItem, "Subject") %></asp:HyperLink>

<%@ Register TagPrefix="TTVS" TagName="MAINHEADER"
Src="/MainHeader.ascx" %>
<%@ Register TagPrefix="TTVS" TagName="MAINFOOTER"
Src="/MainFooter.ascx" %>
<%@ Page language="c#" Codebehind="MessageCenter.aspx.cs"
AutoEventWireup="false" Inherits="TTVS.Admin_MessageCenter" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>System Administration</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<link href="/Base.css" type="text/css" rel="stylesheet">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<div class="Main">
<table class="Main">
<tr>
<td><TTVS:MAINHEADER id="MainHeader"
runat="server"></TTVS:MAINHEADER></td>
</tr>
<tr>
<td>
<asp:Label id="lblPageTitle" runat="server"
CssClass="Two"></asp:Label>
</td>
</tr>
<tr>
<td>
<table class="Expand">
<asp:Repeater id="rptMessageSummary" runat="server">
<ItemTemplate>
<tr>
<td width="40">
<asp:Label Runat="server" CssClass="Three">
<%# DataBinder.Eval(Container.DataItem, "Priority") %>
</asp:Label>
</td>
<td width="100">
<asp:Label Runat="server" CssClass="Three">
<%#
((DateTime)(DataBinder.Eval(Container.DataItem,"Da teTime"))).ToString("ddMMMyy
HH:mm:ss").ToUpper() %>
</asp:Label>
</td>
<td width="125">
<asp:Label Runat="server" CssClass="Three">
<%# DataBinder.Eval(Container.DataItem, "From") %>
</asp:Label>
</td>
<td width="535">

<!-- BELOW IS THE PROBLEM LINE -->
<asp:HyperLink id="Test" Target="_blank" Runat="server"
CssClass="One"
NavigateUrl="/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=<%#
DataBinder.Eval(Container.DataItem, "Number") %>"><%#
DataBinder.Eval(Container.DataItem, "Subject") %></asp:HyperLink>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</td>
</tr>
<tr>
<td>
<TTVS:MAINFOOTER id="MainFooter"
runat="server"></TTVS:MAINFOOTER>
</td>
</tr>
</table>
</div>
</form>
</body>
</HTML>

Nov 19 '05 #1
4 1211
You can't do:
NavigateUrl="/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=<%#
DataBinder.Eval(Container.DataItem, "Number") %>"

Instead you need to use: NavigateUrl='<%#
"/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=" +
DataBinder.Eval(Container.DataItem, "Number") %>'

Besure you use the single quotes at the beginning and the end

-Will
Nov 19 '05 #2
That doesn't work. I tried that first before making the post. I also
tried a couple of other things.

I am pretty sure that Visual Studio does not like the <%#
DataBinder.Eval......%> block within the attributes portion of the
server tag element (it's only the first <#% .... %> that causes the
problem)...but why? How can I make it work?
Will wrote:
You can't do:
NavigateUrl="/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=<%#
DataBinder.Eval(Container.DataItem, "Number") %>"

Instead you need to use: NavigateUrl='<%#
"/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=" +
DataBinder.Eval(Container.DataItem, "Number") %>'

Besure you use the single quotes at the beginning and the end

-Will


Nov 19 '05 #3
Just use the itemdatabound event to define the hyperlink properties.
It is much easier.
Private Sub dg_ItemDataBound(ByVal sender As System.Object, ByVal e As
DataGridItemEventArgs) Handles dg.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then

Dim oHylTest As HyperLink = CType(e.Item.FindControl("Test"),
HyperLink)
oHylTest .NavigateUrl
="/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=" & number &
subject
oHylTest .Text = "code"

End If
End Sub

--
Joe Fallon

<jo*********@topscene.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I have run into a problem with one of my aspx pages. When I run the
page, I get a "Server Tag Is Not Well Formed" error. This message goes
away when I remove the line with the problem. This simply does not make
any sense. I have triple-checked everything. What am I doing wrong
here?

Below is a snippet of the "problem" line. After that is the entire aspx
page, with the "problem" line marked with HTML comment tags...

<asp:HyperLink id="Test" Target="_blank" Runat="server"
CssClass="One"
NavigateUrl="/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=<%#
DataBinder.Eval(Container.DataItem, "Number") %>"><%#
DataBinder.Eval(Container.DataItem, "Subject") %></asp:HyperLink>

<%@ Register TagPrefix="TTVS" TagName="MAINHEADER"
Src="/MainHeader.ascx" %>
<%@ Register TagPrefix="TTVS" TagName="MAINFOOTER"
Src="/MainFooter.ascx" %>
<%@ Page language="c#" Codebehind="MessageCenter.aspx.cs"
AutoEventWireup="false" Inherits="TTVS.Admin_MessageCenter" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>System Administration</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<link href="/Base.css" type="text/css" rel="stylesheet">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<div class="Main">
<table class="Main">
<tr>
<td><TTVS:MAINHEADER id="MainHeader"
runat="server"></TTVS:MAINHEADER></td>
</tr>
<tr>
<td>
<asp:Label id="lblPageTitle" runat="server"
CssClass="Two"></asp:Label>
</td>
</tr>
<tr>
<td>
<table class="Expand">
<asp:Repeater id="rptMessageSummary" runat="server">
<ItemTemplate>
<tr>
<td width="40">
<asp:Label Runat="server" CssClass="Three">
<%# DataBinder.Eval(Container.DataItem, "Priority") %>
</asp:Label>
</td>
<td width="100">
<asp:Label Runat="server" CssClass="Three">
<%#
((DateTime)(DataBinder.Eval(Container.DataItem,"Da teTime"))).ToString("ddMMMyy
HH:mm:ss").ToUpper() %>
</asp:Label>
</td>
<td width="125">
<asp:Label Runat="server" CssClass="Three">
<%# DataBinder.Eval(Container.DataItem, "From") %>
</asp:Label>
</td>
<td width="535">

<!-- BELOW IS THE PROBLEM LINE -->
<asp:HyperLink id="Test" Target="_blank" Runat="server"
CssClass="One"
NavigateUrl="/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=<%#
DataBinder.Eval(Container.DataItem, "Number") %>"><%#
DataBinder.Eval(Container.DataItem, "Subject") %></asp:HyperLink>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</td>
</tr>
<tr>
<td>
<TTVS:MAINFOOTER id="MainFooter"
runat="server"></TTVS:MAINFOOTER>
</td>
</tr>
</table>
</div>
</form>
</body>
</HTML>

Nov 19 '05 #4
On Wed, 13 Jul 2005 17:58:26 -0500, <jo*********@topscene.com> wrote:
That doesn't work. I tried that first before making the post. I also
tried a couple of other things.

I am pretty sure that Visual Studio does not like the <%#
DataBinder.Eval......%> block within the attributes portion of the
server tag element (it's only the first <#% .... %> that causes the
problem)...but why? How can I make it work?

Instead you need to use: NavigateUrl='<%#
"/Admin/MessageCenter/ShowMessage.aspx?Name=MessageID&Value=" +
DataBinder.Eval(Container.DataItem, "Number") %>'

Besure you use the single quotes at the beginning and the end

-Will


I think you want to move your second <%# %> in as the value of the Text
attribute for the hyperlink, not as the innertext of the hyperlink node.

<asp:hyperlink navigateurl='<%# ... %>' text='<%# ... %>'

And do similar to Will's example with making the whole attribute value a
binding expression, and proper use of quotes.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

52 posts views Thread by Tony Marston | last post: by
9 posts views Thread by andrew | last post: by
13 posts views Thread by Jason Huang | last post: by
8 posts views Thread by Midnight Java Junkie | last post: by
669 posts views Thread by Xah Lee | last post: by
10 posts views Thread by JoeC | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.