get the position of an panel

Hi i have this code that get an div and needs to put above an panel to make the loading gif run. but this code was getting the position for an gridview instead of panel, i can't make it work with panels.


<script type="text/javascript" language="javascript">

    function onUpdating() {
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv');
        // make it visible
        updateProgressDiv.style.display = '';
        //  get the wizard element        
        var wizard = $get('<%= UpdatePanel2.ClientID %>');


        // get the bounds of both the wizard and the progress div
        var wizardBounds = Sys.UI.DomElement.getBounds(wizard);

        var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);

        //    do the math to figure out where to position the element (the center of the gridview)
        var x = wizardBounds.x + Math.round(wizardBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
        var y = wizardBounds.y + Math.round(wizardBounds.height / 2) - Math.round(updateProgressDivBounds.height / 2);
        //    set the progress element to this position
        Sys.UI.DomElement.setLocation(updateProgressDiv, x, y);
    }

    function onUpdated() {
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv');
        // make it invisible
        updateProgressDiv.style.display = 'none';
    }

</script>

Open in new window

LVL 1
rafaelrglAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MrunalCommented:
hi,
can you provide your aspx page design code?
It will help.

Also please have a look over this:

http://devarchive.net/update-progress-indicator.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
strickddCommented:
The code below will get the position of an object on the page relative to the top left corner. I included a sample call to the function, but you can pass in any object you want. Remember to use the "ClientID" of your controls because they can be changed when you move them around on the page.
getPosition(document.getElementById('<%= MyPanelID.ClientID %>'));


function getPosition(obj){
    var topValue= 0,leftValue= 0;
    while(obj){
	leftValue+= obj.offsetLeft;
	topValue+= obj.offsetTop;
	obj= obj.offsetParent;
    }
    finalvalue = leftValue + "," + topValue;
    return finalvalue;
}

Open in new window

0
rafaelrglAuthor Commented:
i want that div above the panel. this is so hard. pls help me see what am i doing wrong?
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript" language="javascript">

    


    function getPosition(obj) {
        var topValue = 0, leftValue = 0;
        while (obj) {
            leftValue += obj.offsetLeft;
            topValue += obj.offsetTop;
            obj = obj.offsetParent;
        }
        finalvalue = leftValue + "," + topValue;
        return finalvalue;
    }

    function onUpdating() {
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv');
        // make it visible
        updateProgressDiv.style.display = '';
         //  get the wizard element        
        var wizard = getPosition(document.getElementById('<%= UpdatePanel2.ClientID %>'));


        // get the bounds of both the wizard and the progress div
        var wizardBounds = Sys.UI.DomElement.getBounds(wizard);

        var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);

        //    do the math to figure out where to position the element (the center of the gridview)
        var x = wizardBounds.x + Math.round(wizardBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
        var y = wizardBounds.y + Math.round(wizardBounds.height / 2) - Math.round(updateProgressDivBounds.height / 2);
        //    set the progress element to this position
        Sys.UI.DomElement.setLocation(updateProgressDiv, x, y);
    }

    function onUpdated() {
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv');
        // make it invisible
        updateProgressDiv.style.display = 'none';
    }

</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div class="clearfloat"></div>
     <div id="default_submenu">
         <table style="width: 100%;">
             <tr>
                 <td style="width: 100%;"></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td style="text-align:right;">
                     <uc8:SimpleSearch ID="SimpleSearch1" runat="server" />
                 </td>
             </tr>
         </table>
     </div>     <div class="clearfloat"></div>
     <div>
         <table style="width: 100%;">
             <tr>
                 <td id="default_col_left">
                    <div style="padding-top : 0px; padding-left : 0px;">
                      <T4>Esqueceu seu Password?</T4>
                     <p>
                         Você não pode lembrar seu password? Sem Problema!
                         <br />
                         <br />
                         Preencha alguns dos campos abaixo que nós enviaremos uma mensagem para seu e-mail
                         <br />
                         que especifica-ra como renovar seu password.
                         <br />
                         <br />
                         Por favor entre com seu e-mail ou nome de usuário informado quando você efetuou seu cadastro.
                     </p>
                         <br />
                         <asp:UpdatePanel ID="UpdatePanel2"  ClientIDMode="AutoID" runat="server">
                             <Triggers>
                                  <asp:AsyncPostBackTrigger ControlID="btn_forgotpassword" EventName="Click" />
                             </Triggers>
                             <ContentTemplate>
                                 <asp:Panel ID="panelrecoverpassword"  DefaultButton="btn_forgotpassword" runat="server">
                                    <table>
                                         <tr>
                                             <th align="left" style="width: 130px;">
                                             </th>
                                             <th align="left" style="width: 450px;">
                                             </th>
                                         </tr>
                                         <tr>
                                             <td>
                                                 Email ou usuário:</td>
                                             <td>
                                                 <asp:TextBox ID="TxtEmail" runat="server" SkinID="txtnormal" Width="300px" ValidationGroup="forgotpassword"></asp:TextBox>
                                             </td>
                                         </tr>
                                         <tr>
                                             <td>
                                                 &nbsp;</td>
                                             <td>
                                                 &nbsp;</td>
                                         </tr>
                                         <tr>
                                             <td colspan="2">
                                                 <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Medium" 
                                                     ForeColor="Red"></asp:Label>
                                             </td>
                                         </tr>
                                         <tr>
                                             <td>
                                                 &nbsp;</td>
                                             <td style="text-align: right">
                                                 <asp:Button ID="btn_forgotpassword" OnClick="btn_forgotpassword_Click" runat="server" Text="Recuperar Senha" Height="46px" Width="170px" />
                                             </td>
                                         </tr>
                                     </table>
                                  </asp:Panel>
                             </ContentTemplate>
                        </asp:UpdatePanel>
                         <asp:UpdatePanelAnimationExtender ID="UpdatePanel2_UpdatePanelAnimationExtender" 
                            runat="server" BehaviorID="animation" TargetControlID="UpdatePanel2">
                                            <Animations>
                                                <OnUpdating>
                                                    <Parallel duration="0">
                                                        <ScriptAction Script="onUpdating();" />  
                                                        <EnableAction AnimationTarget="btn_forgotpassword" Enabled="false" />
                                                        <FadeOut minimumOpacity=".5" />
                                                     </Parallel>
                                                </OnUpdating>
                                                <OnUpdated>
                                                    <Parallel duration="0">
                                                        <FadeIn minimumOpacity=".5" />
                                                        <EnableAction AnimationTarget="btn_forgotpassword" Enabled="true" />
                                                        <ScriptAction Script="onUpdated();" /> 
                                                    </Parallel> 
                                                </OnUpdated>
                                            </Animations>
                        </asp:UpdatePanelAnimationExtender>
                     </div>
                 </td>
                 <td id="default_col_right">
                       <uc1:User_Login ID="Login1" runat="server" />
                 </td>
             </tr>
             </table>
     </div>
     <div id="updateProgressDiv" style="display: none;">
          <div style="text-align:center;">
             <asp:Image ID="Image1"  SkinID="Img_Loading01" runat="server" /> Loading...
          </div>
     </div>
</asp:Content>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.