473,776 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with asp:hyperlink

I have an <ASP:HYPERLINKo n 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:HYPERLIN K ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javasc ript:window.ope n('NewWin.aspx? PK=<%#
DataBinder.Eval (Container.Data Item,"PK")%>',' ','toolbar=0,wi dth=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.Data Item,"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 7047
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:wind ow.open('NewWin .aspx?PK={0},'' ,'toolbar=0," +
"width=600,heig ht=600,scollbar s=1')",
DataBinder.Eval (Container.Data Item, "PK")) %>'

--
Dave Sexton

<as****@gmail.c omwrote in message
news:11******** **************@ l12g2000cwl.goo glegroups.com.. .
>I have an <ASP:HYPERLINKo n 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:HYPERLIN K ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javasc ript:window.ope n('NewWin.aspx? PK=<%#
DataBinder.Eval (Container.Data Item,"PK")%>',' ','toolbar=0,wi dth=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.Data Item,"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:wind ow.open('NewWin .aspx?PK={0},'' ,'toolbar=0," +
"width=600,heig ht=600,scollbar s=1')",
DataBinder.Eval (Container.Data Item, "PK")) %>'

--
Dave Sexton

<as****@gmail.c omwrote in message
news:11******** **************@ l12g2000cwl.goo glegroups.com.. .
I have an <ASP:HYPERLINKo n 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:HYPERLIN K ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javasc ript:window.ope n('NewWin.aspx? PK=<%#
DataBinder.Eval (Container.Data Item,"PK")%>',' ','toolbar=0,wi dth=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.Data Item,"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:wind ow.open('NewWin .aspx?PK={0},'' ,'toolbar=0," +
"width=600,heig ht=600,scollbar s=1')",
DataBinder.Eval (Container.Data Item, "PK")) %>'

--
Dave Sexton

<as****@gmail.c omwrote in message
news:11******** **************@ l12g2000cwl.goo glegroups.com.. .
I have an <ASP:HYPERLINKo n 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:HYPERLIN K ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javasc ript:window.ope n('NewWin.aspx? PK=<%#
DataBinder.Eval (Container.Data Item,"PK")%>',' ','toolbar=0,wi dth=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.Data Item,"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(p k)
{
window.open("Ne wWin.aspx?PK=" + pk, "",
"toolbar=0,widt h=600,height=60 0,scollbars=1") ;
}
</script>

And in the template use the following code:

<asp:HyperLin k ID="lnkNewWin" runat="server" NavigateUrl="#"
Text="Click" onclick="javasc ript:showNewWin dow(this.pk)"
pk='<%# DataBinder.Eval (Container.Data Item, "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.c omwrote in message
news:11******** **************@ l39g2000cwd.goo glegroups.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:win dow.open('NewWi n.aspx?PK={0},' ','toolbar=0,"
+
"width=600,heig ht=600,scollbar s=1')",
DataBinder.Eva l(Container.Dat aItem, "PK")) %>'

--
Dave Sexton

<as****@gmail. comwrote in message
news:11******* *************** @l12g2000cwl.go oglegroups.com. ..
>I have an <ASP:HYPERLINKo n 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:HYPERLIN K ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javasc ript:window.ope n('NewWin.aspx? PK=<%#
DataBinder.Eval (Container.Data Item,"PK")%>',' ','toolbar=0,wi dth=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.Data Item,"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="javasc ript:showNewWin dow(this.getAtt ribute('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$******** ******@TK2MSFTN GP04.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(p k)
{
window.open("Ne wWin.aspx?PK=" + pk, "",
"toolbar=0,widt h=600,height=60 0,scollbars=1") ;
}
</script>

And in the template use the following code:

<asp:HyperLin k ID="lnkNewWin" runat="server" NavigateUrl="#"
Text="Click" onclick="javasc ript:showNewWin dow(this.pk)"
pk='<%# DataBinder.Eval (Container.Data Item, "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.c omwrote in message
news:11******** **************@ l39g2000cwd.goo glegroups.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:wi ndow.open('NewW in.aspx?PK={0}, '','toolbar=0,"
+
"width=600,heig ht=600,scollbar s=1')",
DataBinder.Ev al(Container.Da taItem, "PK")) %>'

--
Dave Sexton

<as****@gmail .comwrote in message
news:11****** *************** *@l12g2000cwl.g ooglegroups.com ...
I have an <ASP:HYPERLINKo n 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:HYPERLI NK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javas cript:window.op en('NewWin.aspx ?PK=<%#
DataBinder.Eva l(Container.Dat aItem,"PK")%>', '','toolbar=0,w idth=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.Data Item,"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(p k)
{
window.open("Ne wWin.aspx?PK=" + pk, "",
"toolbar=0,widt h=600,height=60 0,scollbars=1") ;
}
</script>

And in the template use the following code:

<asp:HyperLin k ID="lnkNewWin" runat="server" NavigateUrl="#"
Text="Click" onclick="javasc ript:showNewWin dow(this.pk)"
pk='<%# DataBinder.Eval (Container.Data Item, "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.c omwrote in message
news:11******** **************@ l39g2000cwd.goo glegroups.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:wind ow.open('NewWin .aspx?PK={0},'' ,'toolbar=0,"
+
"width=600,heig ht=600,scollbar s=1')",
DataBinder.Eval (Container.Data Item, "PK")) %>'

--
Dave Sexton

<as****@gmail.c omwrote in message
news:11******** **************@ l12g2000cwl.goo glegroups.com.. .
I have an <ASP:HYPERLINKo n 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:HYPERLIN K ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javasc ript:window.ope n('NewWin.aspx? PK=<%#
DataBinder.Eval (Container.Data Item,"PK")%>',' ','toolbar=0,wi dth=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.Data Item,"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="javasc ript:showNewWin dow(this.getAtt ribute('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$******** ******@TK2MSFTN GP04.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(p k)
{
window.open("Ne wWin.aspx?PK=" + pk, "",
"toolbar=0,widt h=600,height=60 0,scollbars=1") ;
}
</script>

And in the template use the following code:

<asp:HyperLin k ID="lnkNewWin" runat="server" NavigateUrl="#"
Text="Click" onclick="javasc ript:showNewWin dow(this.pk)"
pk='<%# DataBinder.Eval (Container.Data Item, "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.c omwrote in message
news:11******** **************@ l39g2000cwd.goo glegroups.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:win dow.open('NewWi n.aspx?PK={0},' ','toolbar=0,"
+
"width=600,heig ht=600,scollbar s=1')",
DataBinder.Eva l(Container.Dat aItem, "PK")) %>'

--
Dave Sexton

<as****@gmail. comwrote in message
news:11******* *************** @l12g2000cwl.go oglegroups.com. ..
I have an <ASP:HYPERLINKo n 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:HYPERLIN K ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#"
ONCLICK="javasc ript:window.ope n('NewWin.aspx? PK=<%#
DataBinder.Eval (Container.Data Item,"PK")%>',' ','toolbar=0,wi dth=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.Data Item,"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
8955
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. I create the navigatURL from database dynamically. I see the same question mentioned here but the response is not souitable for me: http://www.dotnet247.com/247reference/msgs/11/57708.aspx
3
1979
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) %>" ID="Hyperlink1">BEmail </asp:hyperlink> I would like to construct a url based upon the contents of a textbox. Any ideas?
4
4397
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 possible? This is my hyperlink: <asp:HyperLink id="hplShoppingCart" runat="server" Font-Size="Larger" Font-Names="Arial" NavigateUrl="../forms/ProductOrder.aspx?fn=c">Shopping Cart</asp:HyperLink>
5
6689
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 but here is the snippet of my asp:hyperlink object; <asp:HyperLink NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(Conta iner.DataItem,"CLIENTREF")%> ID="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,...
9
2719
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= '<%# String.Format("Toyota/Images/Showroom/" & Container.DataItem("PathToDisplyPic"))%>' NavigateUrl='<%#
4
2219
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" NavigateUrl="javascript:OpenImage('<%# DataBinder.Eval(Container.DataItem,"FileName") %>');"><%#
5
1227
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 when they click asp:hyperlink points to http://www.mysite.com/myWorkingDirectory/www.userWebSite.com instead of www.userWebSite.com
9
28050
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, "DataItem.name") %>' NavigateUrl='<%# "site.aspx?id=" + DataBinder.Eval (Container.DataItem,"id").ToString()%>' Target="_blank"> </asp:HyperLink>
2
1252
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 "click()" method :( Any body have an idea?
0
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10292
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10122
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9923
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8954
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.