Disabling a button but calling its server code

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Disabling a button but calling its server code

    Hi

    I am trying to create an "Update" button for my form.

    So far I have got it working fine, posting back and
    updating the record. Great!

    However, I now want to make it so that when a user
    presses "Update", the caption changes to "Updating..."
    and the button disables (to prevent multiple form
    submissions).

    I can change the caption of the button easily enough, but
    if I try disabling the button the server code fails to
    run. I suppose this kind of makes sense - why would you
    want to run code for a disabled button - however, to
    achieve what I want I DO NEED to run the code. I have
    tried calling __doPostBack from the buttons onclick event
    but this doesn't work.

    Any ideas?

    Thanks, Paul.

    Paul Guest

  2. Similar Questions and Discussions

    1. disabling enter button (revisited)
      I posted this question before, but all the answers given were not feasible either because it's a VERY long form (so I don't want to make everything...
    2. disabling button control on grid.
      How would I disable a push button control I have in column 2 based on information based on column 1, say a bool field. I figured it would be coded...
    3. Disabling Datagrid Link Button
      Hi all, I have a datagrid with 3 columns with the last one being a link button which does a postback. The page hides/shows a panel control with...
    4. post to server using controls or code other than a button
      Don't forget that the client-side script has a Submit() method that can submit a form without a button. In the following code, I use a literal...
    5. Disabling Command button if Table can't be locked
      I am reposting this because my last attempt in a prior message was not very clear. I have created a command button (Reset Main) that is linked...
  3. #2

    Default Re: Disabling a button but calling its server code

    I've tried this but to no avail.

    If I disable the button in jscript and then call
    __doPostBack(xxx_Update) the update event still doesn't
    get called.

    Paul.
    Paul Guest

  4. #3

    Default Re: Disabling a button but calling its server code

    But you dont need to call the __dopostback for button. the button sends
    the Form without __dopostback.

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  5. #4

    Default Re: Disabling a button but calling its server code

    Try to disable the button with some delay. Instead of "disabled=true", try
    "window.setTimeout('PartyEdit_Update.disabled=true ', 100)"

    --
    H. Ivanov [MS]
    Please reply to newsgroup.


    "Paul" <qwe@qwe.com> wrote in message
    news:02df01c33f33$6e8ef350$a101280a@phx.gbl...
    > Hi Natty
    >
    > I have tried this and the button disables but the form
    > doesn't post back.
    >
    > Heres the server code I use:
    > this.Update.Attributes["onclick"] = this.Update.ClientID
    > + ".disabled=true;";
    >
    > And this results in this on the client:
    > <input type="submit" name="PartyEdit:Update"
    > value="Update" onclick="PartyEdit_Update.disabled=true;if
    > (typeof(Page_ClientValidate) == 'function')
    > Page_ClientValidate(); " language="javascript"
    > id="PartyEdit_Update" class="UpdateControl" />
    >
    > I think the validation code checks to see if the button
    > is enabled and as I've disabled it it fails to run.
    >
    > Paul.

    Hristo Ivanov [MS] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139