views:

321

answers:

4

Hi, I need help in the following scenario: On click of a SAVE button in aspx page,some processing will take place. The processing can be of 10-15 minutes.I want to disable the SAVE button till process ends and once process completes, the SAVE button should be enabled. I tried the following but couldnot solve the problem: 1)Client Side Scripting: I called a java script on client clik of button and set the disable property to true.How ever, server side saveButton_Click event is not called because of disabling the button on client side. 2)Disabling in saveButton_Click method on server side: In this case, as the call of saveButton_Click already happend and requested is sent to server,the client side is as it without any difference until the request is processed.

Please help me in this asap. Its very URGENT.

Thanks Rupa

A: 

You said: "1)Client Side Scripting: I called a java script on client clik of button and set the disable property to true.How ever, server side saveButton_Click event is not called because of disabling the button on client side." and this means the button is now disabled and call to the server side will not be processed untill you re-enabale the button. So is it not meeting your requirement?

Kangkan
+1  A: 

Use System.Threading.Thread.Sleep(5000) in your button click and make it disabled...

For ref Disable submit button

Pandiya Chendur
A: 

You could use a dummy submit button:

<%@ Page Language="C#" AutoEventWireup="true" %>
<script type="text/C#" runat="server">
    protected void BtnClick(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(2000);
        result.Text = DateTime.Now.ToLongTimeString();
    }
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <button type="button" onclick="this.disabled='disabled';document.getElementById('<%= btn.ClientID %>').click();">Start processing</button>
    <asp:Button ID="btn" runat="server" OnClick="BtnClick" style="display:none;" />
    <asp:Label ID="result" runat="server" />
    </form>
</body>
</html>
Darin Dimitrov
@Darin plz help me out http://stackoverflow.com/questions/2507844/how-to-use-jquery-to-paginate-json-data
Pandiya Chendur
A: 

Well the problem lies that you want to toggle a client button attribute after the server processing is complete. But you have no callback for this server function. As you said, disabling on server side will have no effect.

Your best bet would be to put your server functionality into an AJAX-enabled web service. Use jQuery (or regular MS Ajax) to on click: disable button, call AJAX web service, attach success handler to call and in success function re-enable the drop down.

I did a similar thing recently with jQuery's getJSON function where i wanted to (on selected index change of a drop down), disable another drop down, set loading text, call JSON-web service, on success bind results to drop down and re-enable.

RPM1984