Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP.Net Hyperlink

    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.

  • #2
    New Coder
    Join Date
    Jun 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #4
    New Coder
    Join Date
    Jun 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    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
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #6
    New Coder
    Join Date
    Jun 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •