Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Double submit

0 views
Skip to first unread message

Arne Garvander

unread,
May 6, 2008, 3:20:03 PM5/6/08
to
Where can I find a button that can only be submitted only once?
Does the Ajax controlkit have such a button ?
--
Arne Garvander
Certified Geek
Professional Data Dude

Mark Rae [MVP]

unread,
May 6, 2008, 3:51:36 PM5/6/08
to
"Arne Garvander" <ArneGa...@discussions.microsoft.com> wrote in message
news:015F4FF0-5453-4A87...@microsoft.com...

> Where can I find a button that can only be submitted only once?

If you mean how to stop a button from being clicked twice, Anthem, the thin
wrapper around Ajax, has exactly this:
http://www.anthemdotnet.com/examples/MoreButtonProperties.aspx via the
EnabledDuringCallBack property.


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Arne Garvander

unread,
May 6, 2008, 4:06:00 PM5/6/08
to
I tried
If IsPostBack Then
Return
End If
It did absolute nothing to prevent multiple submit.
Why would I think that the update panel trick would do anything?

--
Arne Garvander
Certified Geek
Professional Data Dude


"Lucid" wrote:

> You could put any button in the Ajax update panel and it will do this. Or
> in the Page_Load you could always throw in a if(Page.IsPostBack( { return; }


> "Arne Garvander" <ArneGa...@discussions.microsoft.com> wrote in message
> news:015F4FF0-5453-4A87...@microsoft.com...

darrel

unread,
May 6, 2008, 4:08:26 PM5/6/08
to

> Where can I find a button that can only be submitted only once?
> Does the Ajax controlkit have such a button ?

Other options:

- via javascript, attach an ONCLICK event that disables the button once
clicked.

- handle the problem server-side by checking to see if whatever executes on
click was already triggered int he past x seconds.

-Darrel


Arne Garvander

unread,
May 6, 2008, 4:12:00 PM5/6/08
to
Thanks for the tip.
<script language="javascript">
function SingleSubmit()
{
document.getElementById('Button1').disabled = true;
return true;
}
</script>
<asp:Button ID="Button1" OnClientClick="return SingleSubmit()"
runat="server" Text="Button" />

--
Arne Garvander
Certified Geek
Professional Data Dude

Mark Rae [MVP]

unread,
May 6, 2008, 4:14:34 PM5/6/08
to
"Lucid" <lu...@phreak2000.com> wrote in message
news:743EE001-A89A-4DB4...@microsoft.com...

> You could put any button in the Ajax update panel and it will do this.

How?

> Or in the Page_Load you could always throw in a if(Page.IsPostBack( {
> return; }

How would that stop the page being submitted more than once...?

Mark Rae [MVP]

unread,
May 6, 2008, 4:16:43 PM5/6/08
to
"darrel" <not...@nowhere.com> wrote in message
news:uBVW0T7r...@TK2MSFTNGP05.phx.gbl...

>> Where can I find a button that can only be submitted only once?
>> Does the Ajax controlkit have such a button ?
>
> Other options:
>
> - via javascript, attach an ONCLICK event that disables the button once
> clicked.

You can't disable a button once the postback has begun and, if you disable
it first, the postback won't actually happen...

Mark Rae [MVP]

unread,
May 6, 2008, 4:22:14 PM5/6/08
to
"Arne Garvander" <ArneGa...@discussions.microsoft.com> wrote in message
news:96FD06F2-BEC5-4EA1...@microsoft.com...

[top-posting corrected]

> <script language="javascript">

The language tag has been deprecated for years, and shouldn't be used. The
correct way to begin a client-side JavaScript block is:

<script type="text/javascript">

> function SingleSubmit()
> {
> document.getElementById('Button1').disabled = true;
> return true;
> }
> </script>
> <asp:Button ID="Button1" OnClientClick="return SingleSubmit()"
> runat="server" Text="Button" />

Does this actually work...?

Lucid

unread,
May 6, 2008, 5:09:39 PM5/6/08
to
Miss understood the question, thought he was talking about data being
submitted twice on a single button click. Theres always the code-behind
route in the onclick event. Just add a ButtonName.Enabled = False; when the
request was successfully sent.

"Mark Rae [MVP]" <ma...@markNOSPAMrae.net> wrote in message
news:%23viNOX7...@TK2MSFTNGP05.phx.gbl...

darrel

unread,
May 6, 2008, 5:24:45 PM5/6/08
to
> You can't disable a button once the postback has begun and, if you disable
> it first, the postback won't actually happen...

Hmm...you may be right. I know I've done this before. I think instead of
disabling it, I may have moved it off screen and replaced it with
'submitting form...' text or something.

I'll have to dig through some old code to find it...

-Darrel


0 new messages