473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with asp:hyperlink

I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to
open a new window with no toolbar and specific height & width onclick
of the link. I also want to pass the PK to this new window.

<ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javascript:window.open('NewWin.aspx?PK=<% #
DataBinder.Eval(Container.DataItem,"PK")%>','','to olbar=0,width=600,height=600,scollbars=1')"
TEXT="Click"></ASP:HYPERLINK>

The above code throws an error "Server tag is not well formed".

I am using ONCLICK because I want to specify toolbar=no and height &
width for the new window.

If I replace this <%# DataBinder.Eval(Container.DataItem,"PK")%>
with a numeric value (say 10) then it works fine.

Anyone knows what is wrong with the syntax?

Thanks,
Ashish

Nov 28 '06 #1
7 7028
Hi Ashish,

The property binding syntax must encapsulate the entire value of the
property and must be surrounded by apostrophes, not quotes, IIRC. Try this
instead:

onclick='<%#
string.Format("javascript:window.open('NewWin.aspx ?PK={0},'','toolbar=0," +
"width=600,height=600,scollbars=1')",
DataBinder.Eval(Container.DataItem, "PK")) %>'

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
>I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to
open a new window with no toolbar and specific height & width onclick
of the link. I also want to pass the PK to this new window.

<ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javascript:window.open('NewWin.aspx?PK=<% #
DataBinder.Eval(Container.DataItem,"PK")%>','','to olbar=0,width=600,height=600,scollbars=1')"
TEXT="Click"></ASP:HYPERLINK>

The above code throws an error "Server tag is not well formed".

I am using ONCLICK because I want to specify toolbar=no and height &
width for the new window.

If I replace this <%# DataBinder.Eval(Container.DataItem,"PK")%>
with a numeric value (say 10) then it works fine.

Anyone knows what is wrong with the syntax?

Thanks,
Ashish

Nov 28 '06 #2
Thank you for your help dave.
I tried the code you have given but I am still seeing the same error -
"server tag not well formed".

-Ashish.

Dave Sexton wrote:
Hi Ashish,

The property binding syntax must encapsulate the entire value of the
property and must be surrounded by apostrophes, not quotes, IIRC. Try this
instead:

onclick='<%#
string.Format("javascript:window.open('NewWin.aspx ?PK={0},'','toolbar=0," +
"width=600,height=600,scollbars=1')",
DataBinder.Eval(Container.DataItem, "PK")) %>'

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to
open a new window with no toolbar and specific height & width onclick
of the link. I also want to pass the PK to this new window.

<ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javascript:window.open('NewWin.aspx?PK=<% #
DataBinder.Eval(Container.DataItem,"PK")%>','','to olbar=0,width=600,height=600,scollbars=1')"
TEXT="Click"></ASP:HYPERLINK>

The above code throws an error "Server tag is not well formed".

I am using ONCLICK because I want to specify toolbar=no and height &
width for the new window.

If I replace this <%# DataBinder.Eval(Container.DataItem,"PK")%>
with a numeric value (say 10) then it works fine.

Anyone knows what is wrong with the syntax?

Thanks,
Ashish
Nov 28 '06 #3
Thank you for your help Dave.
I tried the code you have given but I am still seeing the same error -
"server tag not well formed". By the way what is IIRC?
Thanks,
-Ashish
Dave Sexton wrote:
Hi Ashish,

The property binding syntax must encapsulate the entire value of the
property and must be surrounded by apostrophes, not quotes, IIRC. Try this
instead:

onclick='<%#
string.Format("javascript:window.open('NewWin.aspx ?PK={0},'','toolbar=0," +
"width=600,height=600,scollbars=1')",
DataBinder.Eval(Container.DataItem, "PK")) %>'

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to
open a new window with no toolbar and specific height & width onclick
of the link. I also want to pass the PK to this new window.

<ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javascript:window.open('NewWin.aspx?PK=<% #
DataBinder.Eval(Container.DataItem,"PK")%>','','to olbar=0,width=600,height=600,scollbars=1')"
TEXT="Click"></ASP:HYPERLINK>

The above code throws an error "Server tag is not well formed".

I am using ONCLICK because I want to specify toolbar=no and height &
width for the new window.

If I replace this <%# DataBinder.Eval(Container.DataItem,"PK")%>
with a numeric value (say 10) then it works fine.

Anyone knows what is wrong with the syntax?

Thanks,
Ashish
Nov 28 '06 #4
Hi Ashish,

The reason it doesn't work is because the string being bound contains
apostrophes, so ASP.NET thinks that your string is ending earlier than it
should when it's being parsed. Complex javascript like that should be
extracted into a script:

<script type="text/javascript">
function showNewWindow(pk)
{
window.open("NewWin.aspx?PK=" + pk, "",
"toolbar=0,width=600,height=600,scollbars=1");
}
</script>

And in the template use the following code:

<asp:HyperLink ID="lnkNewWin" runat="server" NavigateUrl="#"
Text="Click" onclick="javascript:showNewWindow(this.pk)"
pk='<%# DataBinder.Eval(Container.DataItem, "PK") %>'>
</asp:HyperLink>

I'm taking advantage of DHTML expando by adding a custom attribute: pk.

Be sure to place the entire data-binding expression on one line.

If you're using the 2.0 framework you can use <%# Eval("PK") %instead of
the entire data-binding expression.

BTW, the acronym IIRC stands for "If I remember correctly"

(The acronym BTW stands for "by the way" :)

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l39g2000cwd.googlegr oups.com...
Thank you for your help Dave.
I tried the code you have given but I am still seeing the same error -
"server tag not well formed". By the way what is IIRC?
Thanks,
-Ashish
Dave Sexton wrote:
>Hi Ashish,

The property binding syntax must encapsulate the entire value of the
property and must be surrounded by apostrophes, not quotes, IIRC. Try
this
instead:

onclick='<%#
string.Format("javascript:window.open('NewWin.asp x?PK={0},'','toolbar=0,"
+
"width=600,height=600,scollbars=1')",
DataBinder.Eval(Container.DataItem, "PK")) %>'

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googleg roups.com...
>I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to
open a new window with no toolbar and specific height & width onclick
of the link. I also want to pass the PK to this new window.

<ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javascript:window.open('NewWin.aspx?PK=<% #
DataBinder.Eval(Container.DataItem,"PK")%>','','to olbar=0,width=600,height=600,scollbars=1')"
TEXT="Click"></ASP:HYPERLINK>

The above code throws an error "Server tag is not well formed".

I am using ONCLICK because I want to specify toolbar=no and height &
width for the new window.

If I replace this <%# DataBinder.Eval(Container.DataItem,"PK")%>
with a numeric value (say 10) then it works fine.

Anyone knows what is wrong with the syntax?

Thanks,
Ashish

Nov 28 '06 #5
Hi Ashish,

Apparently the javascript I gave you doesn't work in FireFox (I tested it on
a hunch after I submitted my reply - sorry ;).

Try the following, which works for me in FireFox and IE7:

onclick="javascript:showNewWindow(this.getAttribut e('pk'));"

If you test other browsers, please let me know if this doesn't work for you.

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:O$**************@TK2MSFTNGP04.phx.gbl...
Hi Ashish,

The reason it doesn't work is because the string being bound contains
apostrophes, so ASP.NET thinks that your string is ending earlier than it
should when it's being parsed. Complex javascript like that should be
extracted into a script:

<script type="text/javascript">
function showNewWindow(pk)
{
window.open("NewWin.aspx?PK=" + pk, "",
"toolbar=0,width=600,height=600,scollbars=1");
}
</script>

And in the template use the following code:

<asp:HyperLink ID="lnkNewWin" runat="server" NavigateUrl="#"
Text="Click" onclick="javascript:showNewWindow(this.pk)"
pk='<%# DataBinder.Eval(Container.DataItem, "PK") %>'>
</asp:HyperLink>

I'm taking advantage of DHTML expando by adding a custom attribute: pk.

Be sure to place the entire data-binding expression on one line.

If you're using the 2.0 framework you can use <%# Eval("PK") %instead of
the entire data-binding expression.

BTW, the acronym IIRC stands for "If I remember correctly"

(The acronym BTW stands for "by the way" :)

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l39g2000cwd.googlegr oups.com...
>Thank you for your help Dave.
I tried the code you have given but I am still seeing the same error -
"server tag not well formed". By the way what is IIRC?
Thanks,
-Ashish
Dave Sexton wrote:
>>Hi Ashish,

The property binding syntax must encapsulate the entire value of the
property and must be surrounded by apostrophes, not quotes, IIRC. Try
this
instead:

onclick='<%#
string.Format("javascript:window.open('NewWin.as px?PK={0},'','toolbar=0,"
+
"width=600,height=600,scollbars=1')",
DataBinder.Eval(Container.DataItem, "PK")) %>'

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l12g2000cwl.google groups.com...
I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to
open a new window with no toolbar and specific height & width onclick
of the link. I also want to pass the PK to this new window.

<ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javascript:window.open('NewWin.aspx?PK=< %#
DataBinder.Eval(Container.DataItem,"PK")%>','','t oolbar=0,width=600,height=600,scollbars=1')"
TEXT="Click"></ASP:HYPERLINK>

The above code throws an error "Server tag is not well formed".

I am using ONCLICK because I want to specify toolbar=no and height &
width for the new window.

If I replace this <%# DataBinder.Eval(Container.DataItem,"PK")%>
with a numeric value (say 10) then it works fine.

Anyone knows what is wrong with the syntax?

Thanks,
Ashish


Nov 28 '06 #6
Yes, this works fine!!!
Thanks a lot Dave. It was a great idea to have an attribute PK & pass
its value to a function.
Thank you again,
Ashish.
Dave Sexton wrote:
Hi Ashish,

The reason it doesn't work is because the string being bound contains
apostrophes, so ASP.NET thinks that your string is ending earlier than it
should when it's being parsed. Complex javascript like that should be
extracted into a script:

<script type="text/javascript">
function showNewWindow(pk)
{
window.open("NewWin.aspx?PK=" + pk, "",
"toolbar=0,width=600,height=600,scollbars=1");
}
</script>

And in the template use the following code:

<asp:HyperLink ID="lnkNewWin" runat="server" NavigateUrl="#"
Text="Click" onclick="javascript:showNewWindow(this.pk)"
pk='<%# DataBinder.Eval(Container.DataItem, "PK") %>'>
</asp:HyperLink>

I'm taking advantage of DHTML expando by adding a custom attribute: pk.

Be sure to place the entire data-binding expression on one line.

If you're using the 2.0 framework you can use <%# Eval("PK") %instead of
the entire data-binding expression.

BTW, the acronym IIRC stands for "If I remember correctly"

(The acronym BTW stands for "by the way" :)

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l39g2000cwd.googlegr oups.com...
Thank you for your help Dave.
I tried the code you have given but I am still seeing the same error -
"server tag not well formed". By the way what is IIRC?
Thanks,
-Ashish
Dave Sexton wrote:
Hi Ashish,

The property binding syntax must encapsulate the entire value of the
property and must be surrounded by apostrophes, not quotes, IIRC. Try
this
instead:

onclick='<%#
string.Format("javascript:window.open('NewWin.aspx ?PK={0},'','toolbar=0,"
+
"width=600,height=600,scollbars=1')",
DataBinder.Eval(Container.DataItem, "PK")) %>'

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to
open a new window with no toolbar and specific height & width onclick
of the link. I also want to pass the PK to this new window.

<ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javascript:window.open('NewWin.aspx?PK=<% #
DataBinder.Eval(Container.DataItem,"PK")%>','','to olbar=0,width=600,height=600,scollbars=1')"
TEXT="Click"></ASP:HYPERLINK>

The above code throws an error "Server tag is not well formed".

I am using ONCLICK because I want to specify toolbar=no and height &
width for the new window.

If I replace this <%# DataBinder.Eval(Container.DataItem,"PK")%>
with a numeric value (say 10) then it works fine.

Anyone knows what is wrong with the syntax?

Thanks,
Ashish
Nov 29 '06 #7
Our customers use only IE 6 and above. So I used the first syntax.

Dave Sexton wrote:
Hi Ashish,

Apparently the javascript I gave you doesn't work in FireFox (I tested it on
a hunch after I submitted my reply - sorry ;).

Try the following, which works for me in FireFox and IE7:

onclick="javascript:showNewWindow(this.getAttribut e('pk'));"

If you test other browsers, please let me know if this doesn't work for you.

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:O$**************@TK2MSFTNGP04.phx.gbl...
Hi Ashish,

The reason it doesn't work is because the string being bound contains
apostrophes, so ASP.NET thinks that your string is ending earlier than it
should when it's being parsed. Complex javascript like that should be
extracted into a script:

<script type="text/javascript">
function showNewWindow(pk)
{
window.open("NewWin.aspx?PK=" + pk, "",
"toolbar=0,width=600,height=600,scollbars=1");
}
</script>

And in the template use the following code:

<asp:HyperLink ID="lnkNewWin" runat="server" NavigateUrl="#"
Text="Click" onclick="javascript:showNewWindow(this.pk)"
pk='<%# DataBinder.Eval(Container.DataItem, "PK") %>'>
</asp:HyperLink>

I'm taking advantage of DHTML expando by adding a custom attribute: pk.

Be sure to place the entire data-binding expression on one line.

If you're using the 2.0 framework you can use <%# Eval("PK") %instead of
the entire data-binding expression.

BTW, the acronym IIRC stands for "If I remember correctly"

(The acronym BTW stands for "by the way" :)

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l39g2000cwd.googlegr oups.com...
Thank you for your help Dave.
I tried the code you have given but I am still seeing the same error -
"server tag not well formed". By the way what is IIRC?
Thanks,
-Ashish
Dave Sexton wrote:
Hi Ashish,

The property binding syntax must encapsulate the entire value of the
property and must be surrounded by apostrophes, not quotes, IIRC. Try
this
instead:

onclick='<%#
string.Format("javascript:window.open('NewWin.asp x?PK={0},'','toolbar=0,"
+
"width=600,height=600,scollbars=1')",
DataBinder.Eval(Container.DataItem, "PK")) %>'

--
Dave Sexton

<as****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googleg roups.com...
I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to
open a new window with no toolbar and specific height & width onclick
of the link. I also want to pass the PK to this new window.

<ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javascript:window.open('NewWin.aspx?PK=<% #
DataBinder.Eval(Container.DataItem,"PK")%>','','to olbar=0,width=600,height=600,scollbars=1')"
TEXT="Click"></ASP:HYPERLINK>

The above code throws an error "Server tag is not well formed".

I am using ONCLICK because I want to specify toolbar=no and height &
width for the new window.

If I replace this <%# DataBinder.Eval(Container.DataItem,"PK")%>
with a numeric value (say 10) then it works fine.

Anyone knows what is wrong with the syntax?

Thanks,
Ashish

Nov 29 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Amir Eshterayeh | last post by:
Dear Friends My asp hyperlink goes to relative address instead of absolute. I like navigate url goes to outsite link like www.asp.net but now, it goes to www.mysite/www.asp.net please help....
3
by: Aaron | last post by:
How do I do this? <asp:hyperlink style="Z-INDEX: 144; LEFT: 4px; POSITION: absolute; TOP: 119px" runat="server" Text="Click Me!" NavigateUrl="mailto://<% response.write(txtBEmail.Text.ToString)...
4
by: James P. | last post by:
Hello there, I have an asp hyperlink in a template page. In my user control page - code behind page that uses the template, I'd like to turn this link invisible in certain case. Is it...
5
by: Martin Dew | last post by:
Having some problems getting a hyperlink object to work in my repeater control, It displays the text I have asked it to for the hyperlink, but it does not act as a link. My repeater code is below...
9
by: Leon | last post by:
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks. <asp:datalist id="DataList1" runat="server" RepeatColumns="4"> <ItemTemplate> <asp:HyperLink id=HyperLink1 ImageUrl=...
4
by: Satya | last post by:
Hi all, The following code is throwing a run time error "The server tag is not well formed. " <ItemTemplate> <asp:HyperLink Runat="server" ID="lnkFile"...
5
by: newhorizon | last post by:
I am trying to let the users test if their web adresses are working or not. so they input their web adress and click a button and then the asp:hyperlink will point to their website. the problem is...
9
by: dana lees | last post by:
Hello, I am using asp:HyperLink in a c# asp.net application to open a new window in the following way: <asp:HyperLink ID="lnkSiteName" runat="server" Text='<%# DataBinder.Eval(Container,...
2
by: nicknack | last post by:
Hello. I have an asp:hyperling in my page and I'm trying to make it "clicked" from my code behind. Is this possible? I also tried it with JS but its look like the hyperlink doesn't have a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.