Disable web page controls during postback round-trip

Discussion in 'ASP .Net' started by Sehboo, Dec 10, 2006.

  1. Sehboo

    Sehboo Guest

    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();">
    Sehboo, Dec 10, 2006
    #1
    1. Advertising

  2. Hi,
    Actually following sentence in your code needs to be corrected:
    InCorrect :<form id="Form1" method="post" runat="server"
    onsubmit="stop_input();">
    Correct One : <form id="Form1" method="post" runat="server" onsubmit="return
    stop_input();">

    Anyway two solutions provided in the following URL will surely solve your
    probelm:
    http://www.codersource.net/published/view/284/disabling_mouse_clicks_while_processing.aspx.

    Thanks and regards,
    manish bafna


    "Sehboo" wrote:

    > 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();">
    >
    >
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Dec 10, 2006
    #2
    1. Advertising

  3. Sehboo

    Sehboo Guest

    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

    Manish Bafna wrote:
    > Hi,
    > Actually following sentence in your code needs to be corrected:
    > InCorrect :<form id="Form1" method="post" runat="server"
    > onsubmit="stop_input();">
    > Correct One : <form id="Form1" method="post" runat="server" onsubmit="return
    > stop_input();">
    >
    > Anyway two solutions provided in the following URL will surely solve your
    > probelm:
    > http://www.codersource.net/published/view/284/disabling_mouse_clicks_while_processing.aspx.
    >
    > Thanks and regards,
    > manish bafna
    >
    >
    > "Sehboo" wrote:
    >
    > > 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();">
    > >
    > >
    Sehboo, Dec 12, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Row
    Replies:
    1
    Views:
    683
    vMike
    Nov 26, 2003
  2. =?Utf-8?B?TGFycnk=?=

    Disable web page controls during postback round-trip

    =?Utf-8?B?TGFycnk=?=, Mar 9, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    6,183
    Adrian Parker
    Mar 9, 2006
  3. Sehboo
    Replies:
    1
    Views:
    350
    Mark Fitzpatrick
    Dec 13, 2006
  4. Tony Girgenti
    Replies:
    7
    Views:
    324
    Jasbird
    Apr 1, 2007
  5. moondaddy

    Prevent round trip of postback

    moondaddy, Sep 12, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    899
    moondaddy
    Oct 5, 2007
Loading...

Share This Page