Link to home
Start Free TrialLog in
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

asked on

Display wait message in ASP.Net

Hi Experts,

I want to display some kind of wait message when the server is processing the client request. I am using ASP.net and VB.Net.
Please help.

Thanks.
Avatar of YZlat
YZlat
Flag of United States of America image

you could create a label and write a message to that label right before sending request to the server:

Label1.Text="Processing..."
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

ASKER

Sorry. It did not work.

Thank you for ur reply.
What exactly didn't work? Can you post more details about your application and what is it doing
you could do it with javascript and hidden div on your page:

<div id="WaitLabel" visible="false">
    <img src="some image" />
</div>

Open in new window


and then use javascript to make it visible:

<script language ="javascript" type="text/javascript" >
    
  ShowMessage = function(divName)
     	 {
     		document.getElementById(divName).style.visibility = "visible"
               document.getElementById(divName).innerHTML = 'Please Wait ... '; 
             	return true; //Returns the control to the Server click event
    	  }

</script>

Open in new window

Thank u very much for trying to help me. Here is my code. When I click submit I want to display the "Please wait image"


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   
    <title></title>
    <script type="text/javascript" >

            ShowMessage = function (divName) {
                document.getElementById(divName).style.visibility = "visible"
                document.getElementById(divName).innerHTML = 'Please Wait ... ';
                return true; //Returns the control to the Server click event
            }

    </script>

</head>
<body>
    <form id="form1" runat="server">
     <div style="float:left; width:99.9%;">
        <table>
          <tr>
             <td>
                <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
             </td>                      
          </tr>
        </table>
    </div>

   
   
         <div style="float:left; width:99.4%; margin-left :5px" >
            <asp:GridView ID="GVViewParts" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"  showfooter="true"  Width="99.4%" > <%--OnRowDataBound="setMouseover"--%>
                <AlternatingRowStyle BackColor="White" />
                <%--<EditRowStyle BackColor="#2461BF" />--%>
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                     
                <RowStyle BackColor="#EFF3FB" />
                <%--<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />--%>
                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                <SortedDescendingHeaderStyle BackColor="#4870BE" />
           
            </asp:GridView>
           
       
        </div>

        <div id="WaitLabel" visible="false">
            <img src="Image/Wait.gif" />
        </div>
    </form>
</body>
</html>

 Private Sub LoadCustomers()

        Dim strConnString As String = ConfigurationManager.ConnectionStrings("conn").ConnectionString
        Dim query As String = "SELECT PartID,LionPartNo,ManufacturerPartNo,PartDescription FROM parts"
        Dim cmd As SqlCommand = New SqlCommand(query)
        Dim con As SqlConnection = New SqlConnection(strConnString)
        'Dim sda As SqlDataAdapter = New SqlDataAdapter
        'Dim cmd As SqlCommand = Nothing
        'cmd.CommandText = query
        cmd.Connection = con
        con.Open()
        GVViewParts.DataSource = cmd.ExecuteReader()
        GVViewParts.DataBind()
        con.Close()

    End Sub

    Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
        LoadCustomers()
    End Sub
change btnSubmit as follows:

 
  <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick ="ShowMessage('WaitLabel')" />

Open in new window

Thank you very much. It is working but the image is displaying on form load. I want to display the image only when the button is clicked.  Also How can I display it in the center of the screen. Sorry for asking you very basic questions. I am new to .net programming
Thank u again.
In that case try just removing an image from the div:

<div id="WaitLabel" visible="false">

</div>
How can I display it in the center?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much.