Webform button disabling problems

S

Srinivas

Hi,

I have a webform with some dropdown menus, textboxes required and custom
validators. I added a click event handler for the button in which there is
code for processing. This processing takes around one minute.

I want to disable the button after the user clicks on it so that he cannot
click it again while the processing is going on. But when I do this using
javascript, the button is getting disabled while the form is not getting
submitted.

I used btnSubmit.Attributes.Add("onclick", "disablebutton();") to add onlick
event to the button.

When the page is rendered the button html looks like this

<input type="submit" name="btnSubmit" value="Submit"
onclick="disablebutton();if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate(); " language="javascript" id="btnProceed" />

The javascript for disablebutton() is

function disableButton(){
document.Form1.btnSubmit.value = "Processing..........";
document.Form1.btnSubmit.disabled = true;
}

I don't know where I am going wrong. Can anyone please suggest me how to get
this work.

Thanks

Srinivas
 
G

Guest

Hi

why not change the buttton to be an asp:button rather than a standard input. That way you can use code-behind to handle the event. The clicking of the button should also fire of any webforms validators. You can then just set the command buttons enabled property to false as the last step in the event

The declaration of the button would be simlar to the following

<asp:Button id="cmdNewSection" runat="server" Text="New"></asp:Button

James :)
 
S

Srinivas

Thanks James.

I am already implementing the button as asp:button. The html I posted was
the html as seen using the browsers view source.

Srinivas


James Culshaw said:
Hi,

why not change the buttton to be an asp:button rather than a standard
input. That way you can use code-behind to handle the event. The clicking of
the button should also fire of any webforms validators. You can then just
set the command buttons enabled property to false as the last step in the
event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top