position parenting possible? and how?

Last post 07-09-2008 5:28 AM by ziomdk. 3 replies.

Sort Posts:

  • position parenting possible? and how?

    07-09-2008, 3:12 AM
    • Member
      point Member
    • inx51
    • Member since 05-03-2008, 1:44 PM
    • Posts 68

    Hi!

     Lets say for instance that I have a LinkButton which ID is "LB", and a Div-tag(a layer) which ID is "div"...what i simply want to do is to place the "div" layer at the exact same X-position as the "LB" button....and what I now wonder is, how do I do this with Javascript or anyother language?...I need to do it programmatically, since else I belive that the position of the LB-button and the div-layer will be different if my user has another resulotion then me, or simply has scaled its browser...

    btw if its easy to do the same thing but for the Y-axis aswell...then please let me know howSmile

     

     

    Thanks in advance!

  • Re: position parenting possible? and how?

    07-09-2008, 4:45 AM
    • Member
      266 point Member
    • ziomdk
    • Member since 06-25-2008, 8:54 AM
    • Denmark
    • Posts 58

    I would do something like this:

    var lb = document.getElementById("LB");
    var div = document.getElementById("div");
    
    lb.style.left = div.style.left;
    lb.style.top = div.style.top;
    
     
    										                
    										                
                									    
    Karsten Grau Rasmussen


    Please click on 'Mark as Answer' if this post answered your question!
  • Re: position parenting possible? and how?

    07-09-2008, 5:09 AM
    • Member
      point Member
    • inx51
    • Member since 05-03-2008, 1:44 PM
    • Posts 68

    Hmm...well..something is badly wrong, and I cnat figure out what....Im new to JS so...might need some help on this one...

     

    This is my current code:

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head runat="server">
    
    <title>Untitled Page</title>
    
    </head>
    
    <form id="form1" runat="server">
    
    <script language="javascript">
    
    function findPos(){
    
    var lb = document.getElementById("LB");
    
    var div = document.getElementById("div1");
    
    lb.style.left = div.style.left;
    
    lb.style.top = div.style.top;
    
    }
    
    </script> 
    
    </head>
    
    <body onload="findPos();">
    
    <asp:LinkButton id="LB" runat="server">
    
    Show/hide me
    
    </asp:LinkButton>
    
    <div id="div1" style="display: block; position:absolute; top: 240px; left: 422px;" >
    
    This is the content
    
    </div> 
    
    </body>
    
    </html>
    
    </form>
    
    </body>
    
    </html>
    

     

    well I used ziomdk's code...but I cant understand whats wrong cause the layer(div1) aint getting parentedSad

     

     

     

  • Re: position parenting possible? and how?

    07-09-2008, 5:28 AM
    Answer
    • Member
      266 point Member
    • ziomdk
    • Member since 06-25-2008, 8:54 AM
    • Denmark
    • Posts 58

    You need to define the position attribute of the linkbutton:

    <style>

    .link { position:absolute;

    }

    </style>

     

    <asp:LinkButton CssClass="link" ID="LB" runat="server" Text="Show/hide me"></asp:LinkButton>

    Karsten Grau Rasmussen


    Please click on 'Mark as Answer' if this post answered your question!
Page 1 of 1 (4 items)