Trying to create a hyperlink

W

Wayne Wengert

I am trying to create a hyperlink which calls a specific page and passes
some variables. I am getting an error message on the code section below. The
error states that "the server tag is not well formed". I suspect it is my
syntax? I know the data fields are OK as they display fine in the other
cells.


=====================================================
<td>
<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL= "evaljudge.asp?name=" &
<%#Container.DataItem("JudgeName")%> & "&caption=" &
<%#Container.DataItem("Caption")%>
</asp:HyperLink>
</td>
<td>
<%#Container.DataItem("JudgeName")%>
</td>
<td align="center">
<%#Container.DataItem("Caption")%>
</td>
 
J

Jim Cheshire [MSFT]

Hi Wayne,

The error is right. Here's how the tag should look:

<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL=
"evaljudge.asp?name=<%#Container.DataItem("JudgeName")%>&caption=<%#Containe
r.DataItem("Caption")%>


Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
 
W

Wayne Wengert

Jim;

Thanks for the response but that still generates the same error. I think I
see the way you were going and I'll experiment some more - I suspect the
double quotes are causing a problem.

Wayne


Jim Cheshire said:
Hi Wayne,

The error is right. Here's how the tag should look:

<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL=
evaljudge.asp?name= said:
r.DataItem("Caption")%>


Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
From: "Wayne Wengert" <[email protected]>
Subject: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 09:31:31 -0700
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:19884
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

I am trying to create a hyperlink which calls a specific page and passes
some variables. I am getting an error message on the code section below. The
error states that "the server tag is not well formed". I suspect it is my
syntax? I know the data fields are OK as they display fine in the other
cells.


=====================================================
<td>
<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL= "evaljudge.asp?name=" &
<%#Container.DataItem("JudgeName")%> & "&caption=" &
<%#Container.DataItem("Caption")%>
</asp:HyperLink>
</td>
<td>
<%#Container.DataItem("JudgeName")%>
</td>
<td align="center">
<%#Container.DataItem("Caption")%>
</td>
 
W

Wayne Wengert

If I code it like this I don't get errors but instead of the values from the
datasource I get the actual streing such as"

evaljudge.asp?name=
<%#Container.DataItem('JudgeName')%>&caption=<%#Container.DataItem('Caption'
)%>" >

How can I get the values from the <%#Container.DataItem("xxx") %> calls?

=================== Code Snippett ===============
<td>
<asp:HyperLink id="XX" runat="server" Text = "Edit"
NavigateURL= "evaljudge.asp?name=
<%#Container.DataItem('JudgeName')%>&caption=<%#Container.DataItem('Caption'
)%>" >
</asp:HyperLink>
</td>
<td>
<%#Container.DataItem("JudgeName")%>
</td>
<td align="center">
<%#Container.DataItem("Caption")%>
</td>

Wayne Wengert said:
Jim;

Thanks for the response but that still generates the same error. I think I
see the way you were going and I'll experiment some more - I suspect the
double quotes are causing a problem.

Wayne


Jim Cheshire said:
Hi Wayne,

The error is right. Here's how the tag should look:

<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL=
evaljudge.asp?name= said:
r.DataItem("Caption")%>


Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
From: "Wayne Wengert" <[email protected]>
Subject: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 09:31:31 -0700
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:19884
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

I am trying to create a hyperlink which calls a specific page and passes
some variables. I am getting an error message on the code section
below.
The
error states that "the server tag is not well formed". I suspect it is my
syntax? I know the data fields are OK as they display fine in the other
cells.


=====================================================
<td>
<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL= "evaljudge.asp?name=" &
<%#Container.DataItem("JudgeName")%> & "&caption=" &
<%#Container.DataItem("Caption")%>
</asp:HyperLink>
</td>
<td>
<%#Container.DataItem("JudgeName")%>
</td>
<td align="center">
<%#Container.DataItem("Caption")%>
</td>
 
J

Jim Cheshire [MSFT]

Hi Wayne,

Sorry about that. I didn't see the double quotes. To correct that, simply
enclose the attribute in single quotes. For example:

NavigateURL='evaljudge.asp?name=<%#Container.DataItem("JudgeName")%>&caption
=<%#Container.DataItem("Caption")%>'

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "Wayne Wengert" <[email protected]>
References: <[email protected]>
Subject: Re: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 12:50:45 -0700
Lines: 78
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:19889
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

Jim;

Thanks for the response but that still generates the same error. I think I
see the way you were going and I'll experiment some more - I suspect the
double quotes are causing a problem.

Wayne


Jim Cheshire said:
Hi Wayne,

The error is right. Here's how the tag should look:

<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL=
"evaljudge.asp?name=<%#Container.DataItem("JudgeName")%>&caption=<%#Contain
e
r.DataItem("Caption")%>


Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
From: "Wayne Wengert" <[email protected]>
Subject: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 09:31:31 -0700
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:19884
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

I am trying to create a hyperlink which calls a specific page and passes
some variables. I am getting an error message on the code section below. The
error states that "the server tag is not well formed". I suspect it is my
syntax? I know the data fields are OK as they display fine in the other
cells.


=====================================================
<td>
<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL= "evaljudge.asp?name=" &
<%#Container.DataItem("JudgeName")%> & "&caption=" &
<%#Container.DataItem("Caption")%>
</asp:HyperLink>
</td>
<td>
<%#Container.DataItem("JudgeName")%>
</td>
<td align="center">
<%#Container.DataItem("Caption")%>
</td>
 
W

Wayne Wengert

Jim;

Thanks again but that yields a URL of:


http://localhost:8080/evaljudge.asp?name=<%#Container.DataItem("JudgeName")%>&caption=<%Container.DataItem("Caption")%>

I want the values from the database substituted for the "Container.Item..."
calls.

Wayne

Jim Cheshire said:
Hi Wayne,

Sorry about that. I didn't see the double quotes. To correct that, simply
enclose the attribute in single quotes. For example:
NavigateURL='evaljudge.asp?name= said:
=<%#Container.DataItem("Caption")%>'

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "Wayne Wengert" <[email protected]>
References: <[email protected]>
Subject: Re: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 12:50:45 -0700
Lines: 78
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:19889
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

Jim;

Thanks for the response but that still generates the same error. I think I
see the way you were going and I'll experiment some more - I suspect the
double quotes are causing a problem.

Wayne


Jim Cheshire said:
Hi Wayne,

The error is right. Here's how the tag should look:

<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL=
evaljudge.asp?name= said:
r.DataItem("Caption")%>


Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
From: "Wayne Wengert" <[email protected]>
Subject: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 09:31:31 -0700
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:19884
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

I am trying to create a hyperlink which calls a specific page and passes
some variables. I am getting an error message on the code section below.
The
error states that "the server tag is not well formed". I suspect it is my
syntax? I know the data fields are OK as they display fine in the other
cells.


=====================================================
<td>
<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL= "evaljudge.asp?name=" &
<%#Container.DataItem("JudgeName")%> & "&caption=" &
<%#Container.DataItem("Caption")%>
</asp:HyperLink>
</td>
<td>
<%#Container.DataItem("JudgeName")%>
</td>
<td align="center">
<%#Container.DataItem("Caption")%>
</td>
 
W

Wayne Wengert

Found something that works.

After google'ing I found the following syntax that seems to work,

<td>
<asp:HyperLink id="XX" runat="server"
NavigateUrl = '<%# "http://wengert.org/evaljudge.asp?name=" +
DataBinder.Eval(Container.DataItem,"JudgeName") + "&caption=" +
DataBinder.Eval(Container.DataItem,"Caption")%>'
Text = "Edit" >
</asp:HyperLink>
</td>

I gather you must use the "DataBinder" syntax in this case - Not sure why.
Time for more reading!

Wayne
 
J

Jim Cheshire [MSFT]

Wayne,

I'm not very sure about what you're doing in the absence of the rest of
your application, but there is no DataItem property of the Container
object. If what you are trying to do is bind this property to some
datasource from code-behind, you would typically use DataBinder.Eval and
pass to it the Container and the DataItem that you want to bind.

You can see an example of this by opening the HTML view of any ASPX page
created in VS.NET that contains a data-bound value.

Hope that helps.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "Wayne Wengert" <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: Re: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 15:43:41 -0700
Lines: 140
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:19895
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols


Jim;

Thanks again but that yields a URL of:


http://localhost:8080/evaljudge.asp?name=<%#Container.DataItem("JudgeName")
%>&caption= said:
I want the values from the database substituted for the "Container.Item..."
calls.

Wayne

Jim Cheshire said:
Hi Wayne,

Sorry about that. I didn't see the double quotes. To correct that, simply
enclose the attribute in single quotes. For example:

NavigateURL='evaljudge.asp?name=<%#Container.DataItem("JudgeName")%>&captio
n
=<%#Container.DataItem("Caption")%>'

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "Wayne Wengert" <[email protected]>
References: <[email protected]>
Subject: Re: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 12:50:45 -0700
Lines: 78
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:19889
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

Jim;

Thanks for the response but that still generates the same error. I think I
see the way you were going and I'll experiment some more - I suspect the
double quotes are causing a problem.

Wayne


Hi Wayne,

The error is right. Here's how the tag should look:

<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL=

"evaljudge.asp?name=<%#Container.DataItem("JudgeName")%>&caption=<%#Contai n
e
r.DataItem("Caption")%>


Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
From: "Wayne Wengert" <[email protected]>
Subject: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 09:31:31 -0700
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:19884
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

I am trying to create a hyperlink which calls a specific page and passes
some variables. I am getting an error message on the code section below.
The
error states that "the server tag is not well formed". I suspect it
is
my
syntax? I know the data fields are OK as they display fine in the other
cells.


=====================================================
<td>
<asp:HyperLink id="editlink" runat="server"
Text = "Edit"
NavigateURL= "evaljudge.asp?name=" &
<%#Container.DataItem("JudgeName")%> & "&caption=" &
<%#Container.DataItem("Caption")%>
</asp:HyperLink>
</td>
<td>
<%#Container.DataItem("JudgeName")%>
</td>
<td align="center">
<%#Container.DataItem("Caption")%>
</td>
 
J

Jim Cheshire [MSFT]

Hi Wayne,

Cool. Glad you found this. I actually just replied to your previous post
but didn't see this in our tool until after posting.

You might get better info on why this is the case from someone in the group
who deals with databinding on a regular basis. My team doesn't typically
deal with databinding code (we have a specific team for those kinds of
issues), but the syntax you have in this post is correct.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
 
W

Wayne Wengert

I appreciate all your help

Wayne

Jim Cheshire said:
Hi Wayne,

Cool. Glad you found this. I actually just replied to your previous post
but didn't see this in our tool until after posting.

You might get better info on why this is the case from someone in the group
who deals with databinding on a regular basis. My team doesn't typically
deal with databinding code (we have a specific team for those kinds of
issues), but the syntax you have in this post is correct.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "Wayne Wengert" <[email protected]>
References: <[email protected]>
Subject: Re: Trying to create a hyperlink
Date: Thu, 1 Apr 2004 18:32:40 -0700
Lines: 48
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: c-24-8-108-168.client.comcast.net 24.8.108.168
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:19898
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

Found something that works.

After google'ing I found the following syntax that seems to work,

<td>
<asp:HyperLink id="XX" runat="server"
NavigateUrl = '<%#
"http://wengert.org/evaljudge.asp?name="
+
DataBinder.Eval(Container.DataItem,"JudgeName") + "&caption=" +
DataBinder.Eval(Container.DataItem,"Caption")%>'
Text = "Edit" >
</asp:HyperLink>
</td>

I gather you must use the "DataBinder" syntax in this case - Not sure why.
Time for more reading!

Wayne

below.
The
 

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

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top