• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7513
  • Last Modified:

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

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
jabcoco
Asked:
jabcoco
1 Solution
 
jinn_hnnlCommented:
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
 
jabcocoAuthor Commented:
You rock!
Thanks :)
0
 
tfslnCommented:
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
 
aksharaCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now