473,657 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tricky postback

Hello,

In an aspx page i have webform with some textboxes and a simple
button. When the button is clicked, there is a postback and then the
code in the click event of the button is executed.

However in this code (click event of the button), i'm processing an
online payment, which takes about 5 seconds. While waiting for the
payment to be processed, the user can click again on the button, and
this is what i want to block. I want to disable the button once
clicked, and then execute the code for the web payment.

However when we disable a button in the Load event, the page is only
displayed after the Unload event, so the button still appears as
enabled when executing the code in the click event of the button.

I tried to call a javascript function on the onclick of the button to
disable it but i get a compilation error at runtime. Is there a way to
disable a webform button when clicked, then execute the code on the
Click event of this button? The button needs to appear as disabled on
the page before the code is executed.

Thanks for any help!
Nov 17 '05 #1
7 1487
Even if you disable the button you'll likely have the same problem if the
person refreshes their browser.
To solve this problem, you can generate a unique id for that web page
instance.
If you detect that unique id being posted more than once, then ignore the
subsequent reposts.
Here's a good article on the subject:
http://www.aspnetpro.com/features/20...200309de_f.asp

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net

"Matt" <me***@rocks.co m> wrote in message
news:si******** *************** *********@4ax.c om...
Hello,

In an aspx page i have webform with some textboxes and a simple
button. When the button is clicked, there is a postback and then the
code in the click event of the button is executed.

However in this code (click event of the button), i'm processing an
online payment, which takes about 5 seconds. While waiting for the
payment to be processed, the user can click again on the button, and
this is what i want to block. I want to disable the button once
clicked, and then execute the code for the web payment.

However when we disable a button in the Load event, the page is only
displayed after the Unload event, so the button still appears as
enabled when executing the code in the click event of the button.

I tried to call a javascript function on the onclick of the button to
disable it but i get a compilation error at runtime. Is there a way to
disable a webform button when clicked, then execute the code on the
Click event of this button? The button needs to appear as disabled on
the page before the code is executed.

Thanks for any help!

Nov 17 '05 #2
I had this problem with an authentication page where authenticating the user
took a few seconds and I didn't want them to keep clicking. Basically you
have to do 2 things with 1 click... something to visually alter the screen,
and then handle the actual click in your c/vb.net code.

Make a javascript block to do whatever you need to do on the client when
they click the button. In the example, js renders the button "hidden".

<Script Language="JavaS cript">
function clickHandler()
{
frmLogin.btnLog in.style.visibi lity = 'hidden';
}
</Script>

In my html, here's the submit button the user clicks:

<form ID="frmLogin" runat="server">
<asp:Button ID="btnLogin" class="button" text="Log In"
onclick="Login_ Click" Runat="server" />
</form>

Now in Sub page_load, you need a call to RegisterOnSubmi tStatement. This,
afaik, tells asp.net to run the js function specified then handle the click
event in asp.net:

Sub Page_Load(s As Object, e As EventArgs)
RegisterOnSubmi tStatement("sub mit", "clickHandler() ;")
'...code

So when the user clicks btnLogin on my form, RegisterOnSubmi tStatement calls
the javascript that hides the button, and then my vb.net routine called
"Login_Clic k" would run. 2 routines for the price of 1 click.

You can augment the functionality of the clickHandler(); js routine to
display a please wait message, etc. Just don't damage the integrity of the
button object from the js code or the codebehind handling the button event
may fail. For example, I believe this code breaks if you 'disable' the
button or remove it completely. Hiding it is safe, and certainly renders
the button un-clickable for the remainder of the page life.

HTH
"Matt" <me***@rocks.co m> wrote in message
news:si******** *************** *********@4ax.c om...
Hello,

In an aspx page i have webform with some textboxes and a simple
button. When the button is clicked, there is a postback and then the
code in the click event of the button is executed.

However in this code (click event of the button), i'm processing an
online payment, which takes about 5 seconds. While waiting for the
payment to be processed, the user can click again on the button, and
this is what i want to block. I want to disable the button once
clicked, and then execute the code for the web payment.

However when we disable a button in the Load event, the page is only
displayed after the Unload event, so the button still appears as
enabled when executing the code in the click event of the button.

I tried to call a javascript function on the onclick of the button to
disable it but i get a compilation error at runtime. Is there a way to
disable a webform button when clicked, then execute the code on the
Click event of this button? The button needs to appear as disabled on
the page before the code is executed.

Thanks for any help!

Nov 17 '05 #3
I tried to run your code and I am getting errors
'ASP.WebForm1_a spx' does not contain a definition for 'Login_Click'

???

"eruess" <er****@r.com > wrote in message
news:PI******** ************@sp eakeasy.net...
I had this problem with an authentication page where authenticating the user took a few seconds and I didn't want them to keep clicking. Basically you
have to do 2 things with 1 click... something to visually alter the screen, and then handle the actual click in your c/vb.net code.

Make a javascript block to do whatever you need to do on the client when
they click the button. In the example, js renders the button "hidden".

<Script Language="JavaS cript">
function clickHandler()
{
frmLogin.btnLog in.style.visibi lity = 'hidden';
}
</Script>

In my html, here's the submit button the user clicks:

<form ID="frmLogin" runat="server">
<asp:Button ID="btnLogin" class="button" text="Log In"
onclick="Login_ Click" Runat="server" />
</form>

Now in Sub page_load, you need a call to RegisterOnSubmi tStatement. This,
afaik, tells asp.net to run the js function specified then handle the click event in asp.net:

Sub Page_Load(s As Object, e As EventArgs)
RegisterOnSubmi tStatement("sub mit", "clickHandler() ;")
'...code

So when the user clicks btnLogin on my form, RegisterOnSubmi tStatement calls the javascript that hides the button, and then my vb.net routine called
"Login_Clic k" would run. 2 routines for the price of 1 click.

You can augment the functionality of the clickHandler(); js routine to
display a please wait message, etc. Just don't damage the integrity of the button object from the js code or the codebehind handling the button event
may fail. For example, I believe this code breaks if you 'disable' the
button or remove it completely. Hiding it is safe, and certainly renders
the button un-clickable for the remainder of the page life.

HTH
"Matt" <me***@rocks.co m> wrote in message
news:si******** *************** *********@4ax.c om...
Hello,

In an aspx page i have webform with some textboxes and a simple
button. When the button is clicked, there is a postback and then the
code in the click event of the button is executed.

However in this code (click event of the button), i'm processing an
online payment, which takes about 5 seconds. While waiting for the
payment to be processed, the user can click again on the button, and
this is what i want to block. I want to disable the button once
clicked, and then execute the code for the web payment.

However when we disable a button in the Load event, the page is only
displayed after the Unload event, so the button still appears as
enabled when executing the code in the click event of the button.

I tried to call a javascript function on the onclick of the button to
disable it but i get a compilation error at runtime. Is there a way to
disable a webform button when clicked, then execute the code on the
Click event of this button? The button needs to appear as disabled on
the page before the code is executed.

Thanks for any help!


Nov 17 '05 #4
Got it. Sorry I did not provide the Login_Click Sub in code Behind

"MS News (MS ILM)" <sq**********@h otmail.com> wrote in message
news:uj******** ******@tk2msftn gp13.phx.gbl...
I tried to run your code and I am getting errors
'ASP.WebForm1_a spx' does not contain a definition for 'Login_Click'

???

"eruess" <er****@r.com > wrote in message
news:PI******** ************@sp eakeasy.net...
I had this problem with an authentication page where authenticating the

user
took a few seconds and I didn't want them to keep clicking. Basically you have to do 2 things with 1 click... something to visually alter the

screen,
and then handle the actual click in your c/vb.net code.

Make a javascript block to do whatever you need to do on the client when
they click the button. In the example, js renders the button "hidden".

<Script Language="JavaS cript">
function clickHandler()
{
frmLogin.btnLog in.style.visibi lity = 'hidden';
}
</Script>

In my html, here's the submit button the user clicks:

<form ID="frmLogin" runat="server">
<asp:Button ID="btnLogin" class="button" text="Log In"
onclick="Login_ Click" Runat="server" />
</form>

Now in Sub page_load, you need a call to RegisterOnSubmi tStatement. This, afaik, tells asp.net to run the js function specified then handle the

click
event in asp.net:

Sub Page_Load(s As Object, e As EventArgs)
RegisterOnSubmi tStatement("sub mit", "clickHandler() ;")
'...code

So when the user clicks btnLogin on my form, RegisterOnSubmi tStatement

calls
the javascript that hides the button, and then my vb.net routine called
"Login_Clic k" would run. 2 routines for the price of 1 click.

You can augment the functionality of the clickHandler(); js routine to
display a please wait message, etc. Just don't damage the integrity of

the
button object from the js code or the codebehind handling the button event may fail. For example, I believe this code breaks if you 'disable' the
button or remove it completely. Hiding it is safe, and certainly renders the button un-clickable for the remainder of the page life.

HTH
"Matt" <me***@rocks.co m> wrote in message
news:si******** *************** *********@4ax.c om...
Hello,

In an aspx page i have webform with some textboxes and a simple
button. When the button is clicked, there is a postback and then the
code in the click event of the button is executed.

However in this code (click event of the button), i'm processing an
online payment, which takes about 5 seconds. While waiting for the
payment to be processed, the user can click again on the button, and
this is what i want to block. I want to disable the button once
clicked, and then execute the code for the web payment.

However when we disable a button in the Load event, the page is only
displayed after the Unload event, so the button still appears as
enabled when executing the code in the click event of the button.

I tried to call a javascript function on the onclick of the button to
disable it but i get a compilation error at runtime. Is there a way to
disable a webform button when clicked, then execute the code on the
Click event of this button? The button needs to appear as disabled on
the page before the code is executed.

Thanks for any help!



Nov 17 '05 #5
Login_Click is the name of a Sub in my code. You'll need to modify my post
to have it function within your own project.
When the button is clicked, there is a postback and then the
code in the click event of the button is executed.
However in this code (click event of the button), i'm processing an
online payment, which takes about 5 seconds.<<

So then instead of trying to call my Login_Click (which doesn't exist in
your application) you'll want to call whatever sub does what you described
in the above paragraph... 'Button1_Click' or whatever you / vs.net may have
named it.

Bear in mind with my project, Login_Click did not Handle any control events
(such as clicking), and AutoEventWireUp was False. I have not tested this
thing in a situation where I'm directly calling the sub that also handles
the button's click.

"MS News (MS ILM)" <sq**********@h otmail.com> wrote in message
news:uj******** ******@tk2msftn gp13.phx.gbl... I tried to run your code and I am getting errors
'ASP.WebForm1_a spx' does not contain a definition for 'Login_Click'

???

Nov 17 '05 #6
Thanks, this is exactly what i was looking for! I also added some code
in the javascript function to show a layer, containing a message and
an animated gif acting like a progress bar.

However the gif stops when the web payment code is executed, so the
gif is useless. A flash animation works but i don't want to use flash
in this project.

But the essential is that it works, thanks!

On Thu, 7 Aug 2003 17:14:13 -0700, "eruess" <er****@r.com > wrote:
I had this problem with an authentication page where authenticating the user
took a few seconds and I didn't want them to keep clicking. Basically you
have to do 2 things with 1 click... something to visually alter the screen,
and then handle the actual click in your c/vb.net code.

Make a javascript block to do whatever you need to do on the client when
they click the button. In the example, js renders the button "hidden".

<Script Language="JavaS cript">
function clickHandler()
{
frmLogin.btnLog in.style.visibi lity = 'hidden';
}
</Script>

In my html, here's the submit button the user clicks:

<form ID="frmLogin" runat="server">
<asp:Button ID="btnLogin" class="button" text="Log In"
onclick="Login _Click" Runat="server" />
</form>

Now in Sub page_load, you need a call to RegisterOnSubmi tStatement. This,
afaik, tells asp.net to run the js function specified then handle the click
event in asp.net:

Sub Page_Load(s As Object, e As EventArgs)
RegisterOnSubmi tStatement("sub mit", "clickHandler() ;")
'...code

So when the user clicks btnLogin on my form, RegisterOnSubmi tStatement calls
the javascript that hides the button, and then my vb.net routine called
"Login_Click " would run. 2 routines for the price of 1 click.

You can augment the functionality of the clickHandler(); js routine to
display a please wait message, etc. Just don't damage the integrity of the
button object from the js code or the codebehind handling the button event
may fail. For example, I believe this code breaks if you 'disable' the
button or remove it completely. Hiding it is safe, and certainly renders
the button un-clickable for the remainder of the page life.

HTH
"Matt" <me***@rocks.co m> wrote in message
news:si******* *************** **********@4ax. com...
Hello,

In an aspx page i have webform with some textboxes and a simple
button. When the button is clicked, there is a postback and then the
code in the click event of the button is executed.

However in this code (click event of the button), i'm processing an
online payment, which takes about 5 seconds. While waiting for the
payment to be processed, the user can click again on the button, and
this is what i want to block. I want to disable the button once
clicked, and then execute the code for the web payment.

However when we disable a button in the Load event, the page is only
displayed after the Unload event, so the button still appears as
enabled when executing the code in the click event of the button.

I tried to call a javascript function on the onclick of the button to
disable it but i get a compilation error at runtime. Is there a way to
disable a webform button when clicked, then execute the code on the
Click event of this button? The button needs to appear as disabled on
the page before the code is executed.

Thanks for any help!


Nov 17 '05 #7
Thank you, that is great

"eruess" <er****@r.com > wrote in message
news:NO******** ************@sp eakeasy.net...
Login_Click is the name of a Sub in my code. You'll need to modify my post to have it function within your own project.
When the button is clicked, there is a postback and then the
code in the click event of the button is executed.
However in this code (click event of the button), i'm processing an
online payment, which takes about 5 seconds.<<

So then instead of trying to call my Login_Click (which doesn't exist in
your application) you'll want to call whatever sub does what you described
in the above paragraph... 'Button1_Click' or whatever you / vs.net may

have named it.

Bear in mind with my project, Login_Click did not Handle any control events (such as clicking), and AutoEventWireUp was False. I have not tested this
thing in a situation where I'm directly calling the sub that also handles
the button's click.

"MS News (MS ILM)" <sq**********@h otmail.com> wrote in message
news:uj******** ******@tk2msftn gp13.phx.gbl...
I tried to run your code and I am getting errors
'ASP.WebForm1_a spx' does not contain a definition for 'Login_Click'

???


Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4331
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control displaying the contents of the data source, whilst another control updates the datasource via a command buttons implementation of 'Click', an event raised in the 'Handle Postback Events' stage of the control execution life cycle (via the...
8
11157
by: walesboy | last post by:
greetings - I have a btnSubmit button with a Handles btnSubmit.click which works great if all the user does is click that button. But, if the user ALSO changes a text box on the page (which has it's own event and autopostback=true) before clicking submit then it fires the text box event but never fires the btnSubmit event. (I follow it in the trace). Surely both event handlers should be fired? Any hints on identifying what I
8
1715
by: Shailya | last post by:
We can try writing java script function which will change mouse pointr to Hourglass of entire document. Means we can write two functions 1)Change cursor to hourglass 2)change back to default. Call this function before and after your third party call, this avoides user to click on button
4
3401
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void RaiseCallbackEvent(string eventArgs) { // update the data object with the values currently on screen FormView1.UpdateItem(true); }
1
17035
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
11
14812
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be processed by the web server. I am still struggling to understand this postback logic, and hope that some kind gurus out there could help me clarify the confusion I have.
7
3353
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there is postback occurring? Does that mean a round trip to the server occurred? I keep reading javascript articles and tutorials that say "improve the client-side experience to be more responsive and quicker", but the articles
2
3910
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever possible to make the app more efficient and less resource demanding. On one page there are 2...
2
1317
by: jpavel | last post by:
Hello everyone. I'm having a problem with accessing components. I've looked for a solution in other forums but until now no one have given me any tiny clue about how could I solve it. I know there is a solution to it, but, I couldn't find one. I have a webpage in a website with the the following structure: Main MasterPage LoginView
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.