Why won't my javascript popup window show?

Last post 05-27-2008 7:23 AM by tejesh_kamble. 11 replies.

Sort Posts:

  • Why won't my javascript popup window show?

    10-21-2006, 3:14 PM

    Hi everyone,

    I've been trying to pass a parameter to my popup window but I still can't do it.  I think that I am close because a browser

    window opens but it's a "Page cannot be found" page. 

    Can you tell me what I'm doing wrong?  Do I need the javascript function and the inline javascript?  Here's my code:


    I started with the <head> tag

    <head>
    <script language=javascript>

    function openPopup()

    {

    window.open("largerImage.aspx","title", "Height=300px, Width=300px");

    }
    </script>

     

    </head>

     


    ______________________________________________________________    


    Here's my Hyperlink.  The part I'm having problums with is the NavagateUrl attribute. 


    <asp:HyperLink ImageUrl = '<%# "../images/" + DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server"

    NavigateUrl='<%# javascript:var openPopup = window.open("largerImage.aspx?Param1="& DataBinder.Eval

    (Container.DataItem,"Name")%>> ' ID="Hyperlink1"></asp:HyperLink>


    Why won't my popup window show?  Thanks for any help with this one.

  • Re: Why won't my javascript popup window show?

    10-22-2006, 5:25 PM
    • Star
      12,874 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,357

    Because your code is not right. In your code, you are not taking any parameters for the openPopup method, but here you are "trying" to pass the lasrgerImage.aspx?param1......

    So, from my understanding your code should be as follows

    <script language=javascript>

    function openPopup(var url)

    {

    window.open(url, "title", "Height=300px, Width=300px");

    }
    </script>

    <asp:HyperLink ImageUrl = '<%# "../images/" + DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server"

    NavigateUrl='<%# javascript: openPopup ("largerImage.aspx?Param1="& DataBinder.Eval(Container.DataItem,"Name") &")" %>> ' ID="Hyperlink1"></asp:HyperLink>

     

    Kumar Reddi
  • Re: Why won't my javascript popup window show?

    10-25-2006, 5:03 PM

    Hi Kumar, you code seem very logical but I am getting the error message that states: "The server tag is not well formed".  I've tried moving the quotation marks around but no change.  Here's a copy of it:

    <asp:HyperLink ImageUrl = '<%# "../images/" + DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server" NavigateUrl='<%#javascript:openPopup("largerImage.aspx?Pram1="&DataBinder.Eval(Container.DataItem, "Name")&")"%>>'ID="Hyperlink1">
         </asp:HyperLink>

    The NavigateUrl attribute has a problem but I can't figure it out.  Thanks for helping me with this one.

     

    Alex

  • Re: Why won't my javascript popup window show?

    10-25-2006, 5:09 PM
    • Star
      12,874 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,357

    You have the databinding hash at the wrong place. It should be as follows

    <asp:HyperLink ImageUrl = ' "../images/ + <%#DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server" NavigateUrl='javascript:openPopup("largerImage.aspx?Pram1="&<%#DataBinder.Eval(Container.DataItem, "Name")&")"%>>'ID="Hyperlink1">

    Kumar Reddi
  • Re: Why won't my javascript popup window show?

    10-25-2006, 8:11 PM

    Hi, I still get "The server tag is not well formed" error.  Here's my link:

     

    <asp:HyperLink ImageUrl = ' "../images/ + <%#DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server" NavigateUrl='javascript:openPopup("largerImage.aspx?Pram1="&<%#DataBinder.Eval(Container.DataItem, "Name")&")"%>>'ID="Hyperlink1">

     

     

  • Re: Why won't my javascript popup window show?

    10-25-2006, 8:25 PM
    • Star
      12,874 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,357

    try this 

    <asp:HyperLink ImageUrl = '../images/<%#DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server" 
    NavigateUrl='javascript:openPopup("largerImage.aspx?Pram1=<%#DataBinder.Eval(Container.DataItem, "Name")%> ")'ID="Hyperlink1" ></asp:HyperLink>
    Kumar Reddi
  • Re: Why won't my javascript popup window show?

    10-25-2006, 8:50 PM

    Hi Kumar, thanks for helping me with this.  Unfortunately I’m still having the tag not well formed error.

     

    Here’s a link that works.  This is before I tried to send parameters to the script:

     

     <asp:HyperLink ImageUrl = '<%# "../images/" + DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server" NavigateUrl="javascript:openPopup();" ID="Hyperlink1"></asp:HyperLink>

                                                               

     

    This is my latest try:

     

    sp:HyperLink ImageUrl = '<%# "../images/ + <%#DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server" NavigateUrl='javascript:openPopup("largerImage.aspx?Pram1=<%#DataBinder.Eval(Container.DataItem, "Name")%>")'ID="Hyperlink1">

                                                                </asp:HyperLink>

     

    It looks like it should work but I can’t seem to find the right placements for the quots.

  • Re: Why won't my javascript popup window show?

    10-25-2006, 9:16 PM
    • Star
      12,874 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,357

    Please use the following. You have some single and double quote issues.. The following should clear them up 

    <asp:HyperLink ImageUrl = '../images/ <%#DataBinder.Eval(Container.DataItem, "ImagePath") %>' NavigateUrl='javascript:openPopup("largerImage.aspx?Pram1=<%#DataBinder.Eval(Container.DataItem, \"Name\") %> ")' runat="server" ID="Hyperlink1"> </asp:HyperLink>

     

    Kumar Reddi
  • Re: Why won't my javascript popup window show?

    10-26-2006, 1:10 AM
    • Contributor
      2,209 point Contributor
    • pushp_aspnet
    • Member since 10-19-2006, 1:27 PM
    • Hyderabad,India
    • Posts 447

    Try: 

    <asp:HyperLink ImageUrl = '../images/ <%#DataBinder.Eval(Container.DataItem, "ImagePath") %>' NavigateUrl="javascript:openPopup('largerImage.aspx?Pram1=<%#DataBinder.Eval(Container.DataItem, \"Name\") %> ')" runat="server" ID="Hyperlink1"> </asp:HyperLink>

     

     

    If you have access to the param u want to pass in the .aspx.cs file, u can set the NavigateUrl property of the hyperlink there

     Hyperlink1.NavigateUrl = "";

    Home Is Where the Wind Blows
    http://pushpontech.blogspot.com
  • Re: Why won't my javascript popup window show?

    10-26-2006, 2:04 AM


    Hi the page loads with errors and the hyperlink images aren’t showing.  I suspect it’s this portion of the hyperlink:

      '../images/ <%#DataBinder.Eval()

    When I changed the front end of the tag to look like this:

     '<%# "../images/" + DataBinder.Eval()

     the images loaded but still with the error on page message.

  • Re: Why won't my javascript popup window show?

    10-26-2006, 10:29 AM
    • Star
      12,874 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,357

    I suspect your images does not work has more to do with the value of that databinders. After the page renders view the html source and see if the databinder.eval is returning what you intend it to return

    Kumar Reddi
  • Re: Why won't my javascript popup window show?

    05-27-2008, 7:23 AM
    • Member
      2 point Member
    • tejesh_kamble
    • Member since 04-01-2008, 2:14 AM
    • Posts 1

    Hi ,

    I have the same problem,

    and showing images  with  error on page.

    But this is not neviagating to my another page.

    The java script and hyper line i used are as follows

    </script>
    <script language="javascript" type="text/javascript"  >
    var url;
    function openPopup(var url)
    {
    alert (url);
    window.open(url, "title", "Height=300px, Width=300px");

    }
    </script>

    See this is my code. 

    <asp:HyperLink ImageUrl = ' <%#DataBinder.Eval(Container.DataItem, "HallImageUpload") %>' NavigateUrl='javascript:openPopup("Default2.aspx?ImageUrl=<%#DataBinder.Eval(Container.DataItem, "HallImageUpload") %> ")' runat="server" ID="Hyperlink1"> </asp:HyperLink> 

     

    on click event of image i.e hyperlink i want to nevigate the user to the default2.aspx.

    Please help regarding same.
     

     

     

     


     

Page 1 of 1 (12 items)