...

View Full Version : ASP.Net Hyperlink



esb01
01-12-2005, 08:16 PM
Hello,

I'm using a hyperlink server control.
Dim h As Hyperlink
h.NavigateURL = "abc.aspx"
h.Target = "_blank"

How can I open a window with a specific size and disabled Maximize button?
Like in js onClick="window.open('abc.aspx','win1','width=500,height=500')"

Thanks in advance.

esb01
01-14-2005, 04:00 PM
I came up with a couple ideas but still have a question -

1. This solution works perfect -
<head>...
<script language="JavaScript">
function newWindow(url) {
link = window.open(url,"win1","width=500,height=500");
}
</script>
</head>

and then
Dim hp As Hyperlink
hp.Attributes.Add("onClick", "newWindow('abx.aspx')")

2.What I don't understand why this doesn't work properly -
Dim hp As Hyperlink
hp.NavigateURL = 'javascript:window.open('abc.aspx','win1', 'width=500,height=500');"

for some reasons this code opens 2 new windows - the correct window and a window with
"javascript:window.open 'abc.aspx', 'win1', 'width=500,height=500');"
as a url (which obviously cannot be diplayed)


Any ideas how to fix it?

A1ien51
01-14-2005, 09:04 PM
just do this:

blah.Attributes.Add("onClick", "window.open(this.href,'win1','width=500,height=500');return false;")

then just set the href with the link you want to open in the pop up window.

See if that helps
Eric

esb01
01-14-2005, 10:51 PM
I wasn't asking about blah.Attributes.Add("onClick".....
I understand that it works fine. The only problem is if you set Attributes but not the Navigate URL property you will have to make it to look like a link by setting the Color, Font.Underline = True, and Cursor = Hand properties.

I was asking why
blah.NavigateURL = "javascript:window.open'abc.aspx','win1', 'width=500,height=500');"

doesn't work properly. Why does it open 2 windows and how to fix it?

Thanks

A1ien51
01-14-2005, 11:11 PM
with my soluntion you would add the onclick attribute and you also set the url. The result will be a link that opens up in the new window.

Eric

esb01
01-15-2005, 02:05 AM
thanks for your help Eric

blah.Attributes.Add("onClick", "window.open(this.href,'win1','width=500,height=500');")

actually works fine without return false, but again adding onClick attribute doesn't decorate a text....meanwhile setting NavigateURL property does it automatically



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum