简体   繁体   中英

How to display loading image or text while processing

in my project i am checking links whether its working or not ,when i click on create link button i want to display please wait for while but when and when if their some text in text box1if textbox1.text == null then it should not be display and when its not null then when i will click create button it should show please wait,my code is working but i want to check if their is some value in text box and user click the create button it should show please wait a while .if their no value in textbox1 then if user click on create button then please wait should not be displayed

here is my code

<script type="text/javascript">       

            function ShowProgressBar() {
                if (Textbox1.Text == " ") {
                    document.getElementById('dvProgressBar').style.visibility = "hidden";
                }
                else {
                    document.getElementById('dvProgressBar').style.visibility = "visible";
                }
            }        
    </script>

      <asp:Button ID="Button1" runat="server" Text="Create link" OnClick="btn_createlink_Click" OnClientClick="javascript:ShowProgressBar()" />

    <br />
        <div ID="dvProgressBar" style="visibility: hidden;">
        <div id="content" style="text-align: left; " > 
         Please wait for while...
      </div>
      </div>

    <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="373px" 
        Width="410px" ViewStateMode="Enabled"></asp:TextBox>

From what I understand, you are only asking how to verify if the checkbox is empty, right? This should do it:

<script type="text/javascript">       

function ShowProgressBar() {
    if (document.getElementById('<%=TextBox1.ClientID%>').value == "") {
         document.getElementById('dvProgressBar').style.visibility = "hidden";
    }
    else {
         document.getElementById('dvProgressBar').style.visibility = "visible";
    }
}        
</script>

Easiest way to do this is probably to use ajax . Simply call a web service and use javascript to show a loading message/icon/whatever for the user. Try to use google for this, it's really straightforward.

It has to be asynchronous, or else it would block your UI and the please wait wouldn't show.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM