473,371 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,371 software developers and data experts.

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 1760
"Ramsi" <Ra********@hotmail.com> wrote in news:egDY$YxhEHA.1344
@TK2MSFTNGP11.phx.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********@rogers.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********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"Ramsi" <Ra********@hotmail.com> wrote in news:egDY$YxhEHA.1344
@TK2MSFTNGP11.phx.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********@rogers.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 imgCommencePimpin_Click()
{
if (GameEnabled)
{
GameEnabled = false;
__doPostBack( 'lnkCommencePimpin', '');
}
}
</script>

<ASP:LinkButton ID="lnkCommencePimpin" OnClick="lnkCommencePimpin_Click"
runat=server />
<IMG src="..\Images\CommencePimpin.gif"
onclick="imgCommencePimpin_Click();">

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********************@comcast.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 imgCommencePimpin_Click()
{
if (GameEnabled)
{
GameEnabled = false;
__doPostBack( 'lnkCommencePimpin', '');
}
}
</script>

<ASP:LinkButton ID="lnkCommencePimpin" OnClick="lnkCommencePimpin_Click"
runat=server />
<IMG src="..\Images\CommencePimpin.gif"
onclick="imgCommencePimpin_Click();">

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********************@comcast.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 imgCommencePimpin_Click()
{
if (GameEnabled)
{
GameEnabled = false;
__doPostBack( 'lnkCommencePimpin', '');
}
}
</script>

<ASP:LinkButton ID="lnkCommencePimpin" OnClick="lnkCommencePimpin_Click"
runat=server />
<IMG src="..\Images\CommencePimpin.gif"
onclick="imgCommencePimpin_Click();">

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********@hotmail.com> wrote:
Is it possible to disable a image button through the java script?
Thanks for your reply.
Ramsi
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"Ramsi" <Ra********@hotmail.com> wrote in news:egDY$YxhEHA.1344
@TK2MSFTNGP11.phx.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********@rogers.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...you 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, imgYourButtonImage_Click() will simulate
// the user clicking on lnkYourLinkButton, 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 imgYourButtonImage_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
lnkYourLinkButton
__doPostBack( 'lnkYourLinkButton', '');
}
}
</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
imgYourButtonImage_Click().
Do not set the Visible property to false or this won't work. --%>
<ASP:LinkButton ID="lnkYourLinkButton" OnClick="lnkYourLinkButton_Click"
runat=server />

<%-- This is the place where your button image is displayed to the user.
Whenever it is clicked,
imgYourButtonImage_Click() is called. The style attribute makes
cursor behave as it does
with any other button. --%>
<IMG src="BUTTON_IMAGE_PATH_HERE" onclick="imgYourButtonImage_Click();"
style="cursor:hand">
Nov 18 '05 #8

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

Similar topics

9
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...
33
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...
1
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...
7
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......
3
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...
5
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...
6
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
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.