Disable web page controls during postback round-trip

S

Sehboo

We want to prevent user from being able to click on a button twice or
click on other controls while processing is going on. I tried the
following javascript code (which was suggested in this group but it
didn't really work). User can click on "print" button and then before
postback, they can click on "cancel" button. Any other suggestions?


function ignoreinput() (
return false;


}


function stop_input() {
window.attachEvent(""onkeydown"", ignoreinput); " _
window.attachEvent(""onclick"", ignoreinput); " _


}


Then in the form element of the page add an onsubmit entry..

<form id="Form1" method="post" runat="server" onsubmit="stop_input();">
 
S

Sehboo

Manish,

It didn't work. I am copying the header section from my page here -
maybe I am missing something

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD> <TITLE></TITLE>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<script language="JavaScript">history.forward();
function ignoreinput()
{return false;}
function stop_input()
{
window.attachEvent("onkeydown", ignoreinput);
window.attachEvent("onclick", ignoreinput);
}
</script>
</HEAD>
<BODY LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0 RIGHTMARGIN=0
onLoad='javascript:setDefaultButtonScript()'>
<form name="_ctl16" method="post" action="MyPage.aspx"
language="javascript" onsubmit="return stop_input();" id="_ctl16"
runat="server">

I have two buttons on this page, print and cancel. Print takes about
10 seconds to print the report and cancel just take you back to the
previous page. If I click on print and after two seconds, click on
cancel then it takes me back to the previous page. What I want is that
once user clicks on print, all the other controls should be disabled
(or ignored).

I haven't looked at the other examples on the link - if this doesn't
work then I will look into that.

thanks
 

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,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top