1

I have a UpdatePanel and UpdateProgress inside a User Control.

The position of usercontrol can be controlled from the backend. So need a css which makes the ajax-loader.gif is positioned center to the Div id="main" of my usercontrol. How can i position it ?

Right now, i use the below code...

HTML Rendered :

   <div id="ctl00_ContentPlaceHolder1_ltlsectionRight2">



  <style type="text/css">
 #UpdateProgress1 {
 background-color:#CF4342;
   color:#fff;
   top:0px;
   right:0px;
   position:absolute;
   display:inline;
 }

#UpdateProgress1 img {
   vertical-align:middle;
   margin:2px;
 }
 </style>

<div style="visibility:hidden;display:block;" id="ctl00_ContentPlaceHolder1_GovermentSchemes_UpdateProgress1" role="status" aria-hidden="true">

        <img src="Images/ajax-loader.gif">

    </div>
<div class="title">
    <div class="title-text">
        <div class="title-text-brown">
            Assistance
        </div>
        <div class="title-text-white">
            Schemes</div>
    </div>
</div>
<div id="Main" class="green-box">
    <div class="box-content">
        <table>
            <tbody><tr>
                <td>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    <div id="ctl00_ContentPlaceHolder1_GovermentSchemes_UP1">

                            <select style="width:208px;" id="ctl00_ContentPlaceHolder1_GovermentSchemes_ddlTypes" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$GovermentSchemes$ddlTypes\',\'\')', 0)" name="ctl00$ContentPlaceHolder1$GovermentSchemes$ddlTypes">
            <option value="0" selected="selected">Select Type</option>
            <option value="17">type 1</option>
            <option value="19">type 2</option>

        </select>

    </div>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    <div id="ctl00_ContentPlaceHolder1_GovermentSchemes_UP2">

                            <select style="width:208px;" id="ctl00_ContentPlaceHolder1_GovermentSchemes_ddlSchemes" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$GovermentSchemes$ddlSchemes\',\'\')', 0)" name="ctl00$ContentPlaceHolder1$GovermentSchemes$ddlSchemes">
            <option value="-1">Type is not selected</option>
            <option value="0" selected="selected">Select Scheme</option>

        </select>

    </div>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <div id="ctl00_ContentPlaceHolder1_GovermentSchemes_UP3">

                            <a title="Select Type &amp; Schemes to view." disabled="disabled" id="ctl00_ContentPlaceHolder1_GovermentSchemes_HypView"><img src="uploadedimages/System/Static_Images/search_button.png"></a>

    </div>
                </td>
            </tr>
        </tbody></table>
    </div>
</div>

</div>

ASPX Code :

     <style type="text/css">
     #UpdateProgress1 {
       background-color:#CF4342;
       color:#fff;
       top:0px;
       right:0px;
       position:fixed;
     }

    #UpdateProgress1 img {
       vertical-align:middle;
       margin:2px;
     }
     </style>

    <asp:UpdateProgress ID="UpdateProgress2" runat="server" DynamicLayout="false">
            <ProgressTemplate>
            <div class="progress">
                   <img src="Images/ajax-loader.gif" />  
                    Please Wait...
             </div>
            </ProgressTemplate>
   </asp:UpdateProgress>

    <div id="Main">
    <table> 
                <tr>
                    <td class="style3">
                        <asp:UpdatePanel ID="UP1" runat="server">
                            <ContentTemplate>
                                <asp:DropDownList ID="ddlTypes" runat="server" AutoPostBack="true"  
                                    Width="208px" />
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                </tr>
                <tr>
                    <td class="style3">
                        <asp:UpdatePanel ID="UP2" runat="server">
                            <ContentTemplate>
                                <asp:DropDownList ID="ddlSchemes" runat="server" Width="208px" AutoPostBack="true"
                                    EnableViewState="true">
                                </asp:DropDownList>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="ddlTypes" />
                            </Triggers>
                        </asp:UpdatePanel>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:UpdatePanel ID="UP3" runat="server">
                            <ContentTemplate>
                                <asp:HyperLink ID="HypView" runat="server"><img src="uploadedimages/System/Static_Images/search_button.png" /></asp:HyperLink>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="ddlSchemes" />
                            </Triggers>
                        </asp:UpdatePanel>
                    </td>
                </tr>
            </table>
    </div>
Anuya
  • 8,082
  • 49
  • 137
  • 222
  • check this it should be helpful http://stackoverflow.com/questions/4888223/align-image-in-center-and-middle-within-div – Anant Dabhi Sep 11 '12 at 09:43
  • @AnantDabhi The gif appears on top of the div, i want the gif to be position centered and overlay-ed to DIV id="main" – Anuya Sep 11 '12 at 09:54
  • Please add the outputted HTML code instead of your ASP for easier debug/testing. – Henrik Ammer Sep 11 '12 at 10:16
  • @HenrikAmmer Update with HTML rendered on page. Thanks – Anuya Sep 11 '12 at 10:37
  • In the output you added there is no #UpdateProgress1, therefor no place to even apply the styles to. There is a #ctl00_ContentPlaceHolder1_GovermentSchemes_UpdateProgress1 which I believe is the intended recipient of the CSS, correct? – Henrik Ammer Sep 11 '12 at 11:00
  • I do not see any `
    ` either. Is it in code not shown?
    – Henrik Ammer Sep 11 '12 at 11:03
  • @HenrikAmmer sorry for the mistake i did. I have update the HTML now. Now you can see the proper ID's and classes. What happened was, i was trying to do somethings, and the HTML rendering changed. – Anuya Sep 11 '12 at 11:09
  • Since the updateprogress is outside the #main it has no way of knowing where it is just by using CSS so this is not possible. What you need is to reposition it with, for instance, Javascript. An example is [jQuery UI position](http://jqueryui.com/demos/position/). – Henrik Ammer Sep 11 '12 at 11:19
  • @HenrikAmmer Is it not possible to search for Main div and position the div which has image to the center ? without using jquery ? – Anuya Sep 11 '12 at 11:32
  • Not without some form of processing, be it jQuery, mootools, prototype, classic javascript or vbscript. Yes, CSS takes care of the positioning, but it can not do any form of calculation of other objects and their position if they aren't parent objects. If #UpdateProgress1 is a child object of #main, it can position itself inside #main but not if #UpdateProgress1 and #main are both children to another object. Get it? – Henrik Ammer Sep 11 '12 at 11:46
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16542/discussion-between-henrik-ammer-and-anuya) – Henrik Ammer Sep 11 '12 at 11:49

0 Answers0