Solved

How to hide controls inside UpdatePanel with the UpdateProgress or the UpdatePanelAnimationExtender?

Posted on 2008-10-26
5
7,130 Views
Last Modified: 2012-05-05
Hello Experts!

I'm trying to "Hide" all controls inside the "Update Panel" while the "ajax-loading.gif" controls is show.
My bug is when i click the the "btnOK", the "ajax-loading.gif" is show, but user still able to modify textbox and click on btnOk.

I want to "Hide" or "Disable" access to all controls inside the "update panel" when the updateprogress occur.
When it's finish i want to show back to button to the user.

Any idea, solution or code exemple?

Thanks!
page.aspx

----------------------

<asp:Panel runat="server" ID="panContent" CssClass="ajax_ModalPopup" Style="display: none">

  <asp:UpdatePanel ID="updtPanelModalPopup" runat="server">

    <ContentTemplate>

      Login:<asp:TextBox ID="txtUser" runat="server"></asp:TextBox><br />

      Pass:<asp:TextBox ID="txtPass" runat="server"></asp:TextBox><br />

      <asp:Button ID="btnOk" runat="server" Text="LogOn" />

    </ContentTemplate>

  </asp:UpdatePanel>

  <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updtPanelModalPopup" DynamicLayout="true">

     <ProgressTemplate>

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

      </ProgressTemplate>

  </asp:UpdateProgress>

</asp:Panel>

 

<ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupCtrl"

    PopupControlID="panContent" 

    CancelControlID="btnClose"

    BackgroundCssClass="ajax_ModalPopupBackground"/>
 
 

page.aspx.cs

----------------------

void btnOk_Click(object sender, EventArgs e){

    System.Threading.Thread.Sleep(3000);}

Open in new window

0
Comment
Question by:jabcoco
5 Comments
 
LVL 13

Expert Comment

by:sm394
ID: 22809327
0
 
LVL 10

Accepted Solution

by:
jinn_hnnl earned 500 total points
ID: 22810670
The trick that we used in our project is creating the UpdateProgress as a div which overlap all page controls and cover the whole page.

The div I am talking about will have fixed position start at 0;0; width and height is big enough to cover the entire page. the z-index (important key) is higher than any another (let say 100) so it will overlap the rest of the controls -> no controls is accessible during the progress. The div will also have transparency for better layout using filter (standard CSS).

The Css class .modalProgress  has already cover crossing browser problem. the width and the height I put fixed value to make sure it works for you. You can change it to percentage if you want.

Plug it in your code and see how it's look like

JINN



 

.modalProgress

{ 

	clear:both; 

	float:left; 	

	margin:0px;

	z-index:100;

	position:absolute;

	left:0px;

	top:0px;

	width:1200px;

	height:1000px;			

	background-color:Gray; 

	filter:alpha(opacity=50);

	opacity:0.5;

	-moz-opacity:0.5;

	-khtml-opacity: 0.5;

}
 

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updtPanelModalPopup" DynamicLayout="true">

   <ProgressTemplate>

        <div class="modalProgress">

	   Loading... please wait.... <br />

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

        </div>

   </ProgressTemplate>

</asp:UpdateProgress>

Open in new window

0
 
LVL 10

Author Closing Comment

by:jabcoco
ID: 31510153
You rock!
Thanks :)
0
 

Expert Comment

by:tfsln
ID: 23481598
Would it also be possible for users to use the Tab button to give focus to the overlapped controls, thus meaning it would technically be possible for users to click buttons and such during processing?
0
 

Expert Comment

by:akshara
ID: 25251589
Hi Jinn,

           I am trying to use the same code to hide controls on my page. When i have buttons on the screen, all controls are overlap but it is not happening when i have grid on the page. Below is my html. Could you please help me to resolve this?

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
 <link href="StyleSheet.css" rel="Stylesheet" type="text/css" />
 
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
           
    </div>
   
      <table style="width:55%;">
            <tr>
                <td>
                    <table><tr><td>
                    <asp:UpdatePanel ID="InsertEmployeeUpdatePanel" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                          <table cellpadding="2" border="0" style="background-color:#7C6F57">
                            <tr>
                              <td><asp:Label ID="FirstNameLabel" runat="server" AssociatedControlID="FirstNameTextBox"
                                             Text="First Name" ForeColor="White" /></td>
                              <td><asp:TextBox runat="server" ID="FirstNameTextBox" /></td>
                            </tr>
                            <tr>
                              <td><asp:Label ID="LastNameLabel" runat="server" AssociatedControlID="LastNameTextBox"
                                             Text="Last Name" ForeColor="White" /></td>
                              <td><asp:TextBox runat="server" ID="LastNameTextBox" /></td>
                            </tr>
                            <tr>
                              <td></td>
                              <td>
                                <asp:LinkButton ID="InsertButton" runat="server" Text="Insert" OnClick="InsertButton_Click" ForeColor="White" />
                                <asp:LinkButton ID="InsertButton1" runat="server" Text="Insert 1"  
                                      ForeColor="White" onclick="InsertButton1_Click" />
                                <asp:LinkButton ID="InsertButton2" runat="server" Text="Insert 2"  
                                      ForeColor="White" onclick="InsertButton2_Click" />
                              </td>
                            </tr>
                          </table>
                          <asp:Label runat="server" ID="InputTimeLabel"><%=DateTime.Now %></asp:Label>
                        </ContentTemplate>
                    </asp:UpdatePanel>

                   
                    </td></tr></table></td>
                    <td><table>
                    <tr>
                    <td>
                    <asp:UpdatePanel ID="EmployeesUpdatePanel" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:GridView ID="EmployeesGridView" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
                                BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" AutoGenerateColumns="False">
                                <FooterStyle BackColor="Tan" />
                                <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="Tan" Font-Bold="True" />
                                <AlternatingRowStyle BackColor="PaleGoldenrod" />
                                <Columns>
                                    <asp:BoundField DataField="EmployeeID" HeaderText="Employee ID" />
                                    <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                                    <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                                </Columns>
                                <PagerSettings PageButtonCount="5" />
                            </asp:GridView>
                            <asp:Label runat="server" ID="ListTimeLabel"><%=DateTime.Now %></asp:Label>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="InsertButton" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>

                    </td>
                    </tr>
                    <tr>
                    <td>
                    <asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:GridView ID="GridView1" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
                                BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" AutoGenerateColumns="False">
                                <FooterStyle BackColor="Tan" />
                                <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="Tan" Font-Bold="True" />
                                <AlternatingRowStyle BackColor="PaleGoldenrod" />
                                <Columns>
                                    <asp:BoundField DataField="EmployeeID" HeaderText="Employee ID" />
                                    <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                                    <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                                </Columns>
                                <PagerSettings PageButtonCount="5" />
                            </asp:GridView>
                            <asp:Label runat="server" ID="Label4"><%=DateTime.Now %></asp:Label>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="InsertButton1" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>

                    </td>
                    </tr>
                    <tr>
                    <td>
                    <asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:GridView ID="GridView2" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
                                BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" AutoGenerateColumns="False">
                                <FooterStyle BackColor="Tan" />
                                <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="Tan" Font-Bold="True" />
                                <AlternatingRowStyle BackColor="PaleGoldenrod" />
                                <Columns>
                                    <asp:BoundField DataField="EmployeeID" HeaderText="Employee ID" />
                                    <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                                    <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                                </Columns>
                                <PagerSettings PageButtonCount="5" />
                            </asp:GridView>
                            <asp:Label runat="server" ID="Label5"><%=DateTime.Now %></asp:Label>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="InsertButton2" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>

                    </td>
                    </tr>
                    </table></td>
               
            </tr>
           
           
        </table>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="EmployeesUpdatePanel" >
        <ProgressTemplate>
        <div class="modalProgress">
            <img alt="Data is Loading .........." src="Rotator.gif"
    style="width: 100px; height: 100px" />&nbsp; Data is loding in Panel 1
            .............................</div>
        </ProgressTemplate>
    </asp:UpdateProgress>
             

   
    <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel4" >
        <ProgressTemplate>
        <div class="modalProgress" align="right" >
            <img alt="Panel 2 is Updating ........" src="Rotator.gif"
    style="width: 100px; height: 100px" />&nbsp; Data is loding in Panel 2
            .............................
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
   
    <asp:UpdateProgress ID="UpdateProgress3" runat="server" AssociatedUpdatePanelID="UpdatePanel5" >
        <ProgressTemplate>
        <div class="modalProgress">
            <img alt="Update Panel 3 is Loading ..." src="Rotator.gif"
    style="width: 100px; height: 100px" />
            Data is loding in Panel 3 .............................
            </div>
        </ProgressTemplate>
       
    </asp:UpdateProgress>
   
 
           
    </form>
</body>
</html>

Thanks
Akshara
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now