0

This is a very simple question, yes, but I'm not used to web development yet (I do mostly win apps).

I have a button that does a wide variety of things. The first thing I want it to do is this:

lblStatus.Text = "In progress, please wait...";

Problem is, this is not updating the label's default text "Ready" to "In progress, please wait..." when the button is pressed.

My question is, should I do this like this or should I use something else like AJAX?

JJ.
  • 9,580
  • 37
  • 116
  • 189

5 Answers5

0

If you're using ASP.NET Ajax anyway, you can use the UpdateProgress control which is made for this.

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
0

The "in progress" part is happening while posting back. In the code you've written, the "in progress" would only show on post back, when the response is coming back.

This is a similar problem as using JS to prevent double clicks (and double posts)

Ref: javascript/jquery disable submit button on click, prevent double submitting

Community
  • 1
  • 1
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
0

You can try using AJAX (see URL for samples) http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/

KG Sosa
  • 70
  • 9
0

Details: You could just use jQuery to Show the label when the button is pressed and hide it when page loads

Example:

Jquery

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script  type="text/javascript">

        $(document).ready(function ()
        {
           // Hide the Label to start with
                $('#<%=lblStatus.ClientID %>').hide();

            $('#<%=btnSave.ClientID %>').click(function ()
            {
                // Show the Label when save button is clicked
                $('#<%=lblStatus.ClientID %>').show();
            });
        });

</script>


ASP.NET Controls

<asp:Button ID="btnSave" runat="server" Text="Button" />
<asp:Label ID="lblStatus" CssClass="lblStatus" runat="server" Text="In progress, please wait..."></asp:Label>
MVCKarl
  • 1,283
  • 9
  • 7
0

you can use " UpdateProgress " for this. You only need to add below code in aspx. When you click on button, " In progress, please wait... " will be displayed till the process ends.

<asp:UpdateProgress ID="UpdateProgress1" runat="server">
                <ProgressTemplate>
                    <span style="text-decoration:blink; font-size:small; color:Gray;">
                    In progress, please wait...</span>
                    <%-- you can have image here instead of text--%>
                </ProgressTemplate>
            </asp:UpdateProgress>
Anup
  • 80
  • 1
  • 1
  • 6
  • Anup, how does this text change to "In progress, please wait..." when I click the button? Don't I have to link the pressing of the button to this somehow? – JJ. Nov 20 '12 at 17:31
  • no. you don't need to link it with button. this will display till the process/action is in progress. – Anup Nov 21 '12 at 11:40