What Is Going On Here?

J

joey.powell

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,"DateTime"))).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>
 
G

Guest

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
 
J

joey.powell

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?
 
J

Joe Fallon

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
 
C

Craig Deelsnyder

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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top