473,725 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Design Q - Avoiding two clicks

My development environment is ASP.Net 1.1. Clicked event of a button has
lengthy procedure it will take 2 to 4 seconds to process the data.

My question is,

1.. If the user clicks the button again, will the clicked event called
again?
2.. If yes to the above question how to avoid these kinds of scenarios?
Thanks for your suggestions.
Ramsi
Nov 18 '05 #1
7 1775
"Ramsi" <Ra********@hot mail.com> wrote in news:egDY$YxhEH A.1344
@TK2MSFTNGP11.p hx.gbl:
My development environment is ASP.Net 1.1. Clicked event of a button has
lengthy procedure it will take 2 to 4 seconds to process the data.

My question is,

1.. If the user clicks the button again, will the clicked event called
again?
Yes.
2.. If yes to the above question how to avoid these kinds of scenarios?
Thanks for your suggestions.


-Use javascript to disable the button
-Check if the current function is in progress? Maybe put a flag in the
database?

--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2
Is it possible to disable a image button through the java script?
Thanks for your reply.
Ramsi
"Lucas Tam" <RE********@rog ers.com> wrote in message
news:Xn******** *************** ****@140.99.99. 130...
"Ramsi" <Ra********@hot mail.com> wrote in news:egDY$YxhEH A.1344
@TK2MSFTNGP11.p hx.gbl:
My development environment is ASP.Net 1.1. Clicked event of a button has
lengthy procedure it will take 2 to 4 seconds to process the data.

My question is,

1.. If the user clicks the button again, will the clicked event called
again?


Yes.
2.. If yes to the above question how to avoid these kinds of scenarios? Thanks for your suggestions.


-Use javascript to disable the button
-Check if the current function is in progress? Maybe put a flag in the
database?

--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 18 '05 #3
Ramsi wrote:
Is it possible to disable a image button through the java script?
Thanks for your reply.
Ramsi


Yes and no. I do the following to build this sort of functionalty...
Instead of using an ImageButton for your button, use a LinkButton
instead. Be sure not to specify its text so it is not visible to the
user, and remap your ImageClick event handler to the new LinkButton.
Don't specify its Visible property, the default value of true is
required for this to work. Now, in place of your ImageButton, insert an
IMG tag for your button image. In your page, you will need to define a
javascript function that handles the clientside onClick event for this
IMG tag, and a global variable that tracks the "enabled" state of your
button. The client code should look something like this:

<script lang=javascript >
var GameEnabled = true;

function imgCommencePimp in_Click()
{
if (GameEnabled)
{
GameEnabled = false;
__doPostBack( 'lnkCommencePim pin', '');
}
}
</script>

<ASP:LinkButt on ID="lnkCommence Pimpin" OnClick="lnkCom mencePimpin_Cli ck"
runat=server />
<IMG src="..\Images\ CommencePimpin. gif"
onclick="imgCom mencePimpin_Cli ck();">

This is definitely a hack, but it works unless your button is in a user
control. I'll assume its not, but I can show you how to do that too if
you need to know. BTW, if anyone reading this knows a more convenient
way to insert custom client-side script logic into stock ASP.NET
controls, I'm all ears.

- John
Nov 18 '05 #4
Thank you very much.

"John Hann" <jovinhan@SPAM_ FREEyahoo.com> wrote in message
news:JZ******** ************@co mcast.com...
Ramsi wrote:
Is it possible to disable a image button through the java script?
Thanks for your reply.
Ramsi


Yes and no. I do the following to build this sort of functionalty...
Instead of using an ImageButton for your button, use a LinkButton
instead. Be sure not to specify its text so it is not visible to the
user, and remap your ImageClick event handler to the new LinkButton.
Don't specify its Visible property, the default value of true is
required for this to work. Now, in place of your ImageButton, insert an
IMG tag for your button image. In your page, you will need to define a
javascript function that handles the clientside onClick event for this
IMG tag, and a global variable that tracks the "enabled" state of your
button. The client code should look something like this:

<script lang=javascript >
var GameEnabled = true;

function imgCommencePimp in_Click()
{
if (GameEnabled)
{
GameEnabled = false;
__doPostBack( 'lnkCommencePim pin', '');
}
}
</script>

<ASP:LinkButt on ID="lnkCommence Pimpin" OnClick="lnkCom mencePimpin_Cli ck"
runat=server />
<IMG src="..\Images\ CommencePimpin. gif"
onclick="imgCom mencePimpin_Cli ck();">

This is definitely a hack, but it works unless your button is in a user
control. I'll assume its not, but I can show you how to do that too if
you need to know. BTW, if anyone reading this knows a more convenient
way to insert custom client-side script logic into stock ASP.NET
controls, I'm all ears.

- John

Nov 18 '05 #5
John,
I am finding difficulty to display an image for a Link button.
Thanks,
Ramsi

"John Hann" <jovinhan@SPAM_ FREEyahoo.com> wrote in message
news:JZ******** ************@co mcast.com...
Ramsi wrote:
Is it possible to disable a image button through the java script?
Thanks for your reply.
Ramsi


Yes and no. I do the following to build this sort of functionalty...
Instead of using an ImageButton for your button, use a LinkButton
instead. Be sure not to specify its text so it is not visible to the
user, and remap your ImageClick event handler to the new LinkButton.
Don't specify its Visible property, the default value of true is
required for this to work. Now, in place of your ImageButton, insert an
IMG tag for your button image. In your page, you will need to define a
javascript function that handles the clientside onClick event for this
IMG tag, and a global variable that tracks the "enabled" state of your
button. The client code should look something like this:

<script lang=javascript >
var GameEnabled = true;

function imgCommencePimp in_Click()
{
if (GameEnabled)
{
GameEnabled = false;
__doPostBack( 'lnkCommencePim pin', '');
}
}
</script>

<ASP:LinkButt on ID="lnkCommence Pimpin" OnClick="lnkCom mencePimpin_Cli ck"
runat=server />
<IMG src="..\Images\ CommencePimpin. gif"
onclick="imgCom mencePimpin_Cli ck();">

This is definitely a hack, but it works unless your button is in a user
control. I'll assume its not, but I can show you how to do that too if
you need to know. BTW, if anyone reading this knows a more convenient
way to insert custom client-side script logic into stock ASP.NET
controls, I'm all ears.

- John

Nov 18 '05 #6
On Fri, 20 Aug 2004 18:02:46 -0700, Ramsi <Ra********@hot mail.com> wrote:
Is it possible to disable a image button through the java script?
Thanks for your reply.
Ramsi
"Lucas Tam" <RE********@rog ers.com> wrote in message
news:Xn******** *************** ****@140.99.99. 130...
"Ramsi" <Ra********@hot mail.com> wrote in news:egDY$YxhEH A.1344
@TK2MSFTNGP11.p hx.gbl:
> My development environment is ASP.Net 1.1. Clicked event of a button

has
> lengthy procedure it will take 2 to 4 seconds to process the data.
>
> My question is,
>
> 1.. If the user clicks the button again, will the clicked event

called
> again?


Yes.
> 2.. If yes to the above question how to avoid these kinds of scenarios? > Thanks for your suggestions.


-Use javascript to disable the button
-Check if the current function is in progress? Maybe put a flag in the
database?

--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Yes, you can but would not be my preferred way of doing it....check the
HTML you have right now, it's pry an a href="" wrapped around an img. Add
an onclick attribute to the hyperlink (I think you can do this by setting
it on the ImageButton) and it should run before posting back. So you
could put in that event some javascript that checks a local var that
indicates whether this function ran once before.

The only tricky thing is if you have validators...yo u may want to then
actually override __doPostBack in Javascript and insert the flipping of
the flag there (actually pry the best design regardless)...

http://groups.google.com/groups?hl=e...8%26oe%3Dutf-8

I like this approach better, as it catches double posting by any control
on a page...

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #7
Ramsi wrote:
John,
I am finding difficulty to display an image for a Link button.
Thanks,
Ramsi


I think you missed the key point of my post, which was that you need to
put the button's image in a standard html IMG tag, not an ImageButton or
Link Button. Then, you need to add a javascript onclick event handler to
that IMG tag that calls a javascript function that will trick ASP.Net
into thinking that the user clicked on a LinkButton, even though the
user cannot actually see that LinkButton. I'll resubmit my code with
some additional changes for clarity. Hope this helps.
- John

<script lang=javascript >
// if this variable is true, imgYourButtonIm age_Click() will simulate
// the user clicking on lnkYourLinkButt on, even though it is not
displayed to the user
var ButtonEnabled = true;

// this is called whenever the IMG tag that contains your button
image is clicked
function imgYourButtonIm age_Click()
{
if (ButtonEnabled == true)
{
// this ensures that if the user clicks your button IMG
again, a postback will not occur
ButtonEnabled = false;

// this tells ASP.Net that the user clicked on
lnkYourLinkButt on
__doPostBack( 'lnkYourLinkBut ton', '');
}
}
</script>

<%-- This is the link button that you need to implement a server-side
event handler for.
It is hidden from the user and only "clicked" indirectly from
imgYourButtonIm age_Click().
Do not set the Visible property to false or this won't work. --%>
<ASP:LinkButt on ID="lnkYourLink Button" OnClick="lnkYou rLinkButton_Cli ck"
runat=server />

<%-- This is the place where your button image is displayed to the user.
Whenever it is clicked,
imgYourButtonIm age_Click() is called. The style attribute makes
cursor behave as it does
with any other button. --%>
<IMG src="BUTTON_IMA GE_PATH_HERE" onclick="imgYou rButtonImage_Cl ick();"
style="cursor:h and">
Nov 18 '05 #8

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

Similar topics

9
10281
by: Sebastian Faust | last post by:
Hi, I have a design problem about which I am thinking now for a while and still couldnt find any help in deja. What I need is something like a virtual function template. I know that this is not possible, so I need "something like" a virtual function template. I read in some threads that there is a workaround using the visitor pattern. I read therefore in the book "Modern c++ Design" about this pattern, but couldnt find any help to my...
33
3828
by: Joe | last post by:
I'm designing a company website. I'm relatively new to CSS and I'm having trouble creating what seems to me a very simple design: - body background: fixed full page image - banner: fixed, 100 pixels high, full-width, transparent background - nav bar: fixed, 200 px wide, auto-height, opaque nav icons, semi-transparent tiled image background - content box: scrolling, auto height, auto width, opaque text, semi-transparent tiled image...
1
2052
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able to kick off the process and continue to work in the appliaction while getting progress updates and the ability to cancel. The method that seems easiest to me is this: The class exposes certain events for progress. Start, ProgressUpdate, and...
7
1898
by: perspolis | last post by:
hi I have two table named Purchase and Sale..all of fields of both tables are the same...I make them design in one table with an additional boolean field to determine which is Sale and Purchase... it is good to design them in seperate tables without additional field?? or design both in one table...
3
2135
by: cleo | last post by:
In VB6 my practice was to set control properties at Run Time rather than Design Time. I found setting property values in the code provided better documentation, since much of this was hidden - and if there were problems with a control dll setting values were preserved and not "lost" to the domain of searching code using a DOS editor. However, as I start work in VB.Net I'm questioning if I should continue my practice of avoiding Design...
5
4182
by: Don | last post by:
Is there a way to capture click events in the form designer? I'm trying to create a control similar to the TabControl (which seems to handle clicks in design mode) and would like to be able to click on parts of the control in design mode and have the control react, but I can't seem to trap the events in design mode. - Don
6
14858
by: Brian Simmons | last post by:
Hi all, I come from a ColdFusion background, and the majority of the time, here's how we processed a page: 1) The Data entry page would have a submit button which would post to an action page 2) The action page would do the validation and database processing, if successful, the action page would <cflocation(similar to a Response.Redirect or Server.Transfer) to a display page.
2
1497
by: Joey | last post by:
I have written an app in C#/asp.net 2.0 that is a system built to handle a large number of scenarios. Part of that system involves allowing users to download large files. As part of my original design strategy, I chose to locate these downloads in a directory separate from the website file structure. The two primary purposes for this were: (1) it is more secure because users cannot link directly to the files and (2) it is modular,...
4
1530
by: trullock | last post by:
Hi, Can anyone suggest the best way to go about the following... I'm tracking clicks (mouse down x,y coordinates) on a web page by using some javascript to create an XHR which sends the coordinates to a recording service, such as: /Record.ashx?X=123&Y=456
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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
9257
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
9179
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,...
0
9116
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
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...
1
3228
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
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.