473,382 Members | 1,720 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,382 software developers and data experts.

Disable Linkbutton Before Postback?

I'm using a LinkButton to call some code, then do a redirect. The code
does some queries, sends some emails, and takes a few moments before the
redirect is performed.

I'd like to disable my LinkButton during this period to prevent multiple
submissions. (Obviously) the disabling should be done at the client
side to prevent any delay. I've tried adding some javascript to
LinkButton.Attributes:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'"
+ this.GetPostBackEventReference(this.LinkButton1));

but this doesn't disable the LinkButton. I also tried:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'");

which disables the link, but never does the postback.

This seems like a very important thing to be able to do, and thus it
should be reasonably easy - what am I missing?

Alternatively, perhaps there's something clever that I can do on the
server side to "short circuit" subsequent postbacks?

Thanks,

Al Cohen
Nov 18 '05 #1
6 9048
Hi Al,

I've had that same issue. Usually you have to attach the script code to the
form's OnSubmit().

Actually what I found is that if you disable the button that you're binding
events to the button's event doesn't fire because the button doesn't show up
in the post variable list. Hiding the button actually works better.

I usually do this in the HTML but you should be able to do the same with
attributes:

<form id="frmOrderForm"
onsubmit="this.btnSubmit.style.display='none';docu ment.getElementById('WaitN
ote').style.display='inline';return true;" ... >

This code hides the button and shows an area that has a message.

Works real well, except that I have an animated Gif in there and it doesn't
animate - some bug in IE related to a hidden image not animating, it works
with Mozilla...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Al Cohen" <am***@no.junk.c-o-r-n-e-l-l.edu> wrote in message
news:DM********************@speakeasy.net...
I'm using a LinkButton to call some code, then do a redirect. The code
does some queries, sends some emails, and takes a few moments before the
redirect is performed.

I'd like to disable my LinkButton during this period to prevent multiple
submissions. (Obviously) the disabling should be done at the client
side to prevent any delay. I've tried adding some javascript to
LinkButton.Attributes:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'"
+ this.GetPostBackEventReference(this.LinkButton1));

but this doesn't disable the LinkButton. I also tried:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'");

which disables the link, but never does the postback.

This seems like a very important thing to be able to do, and thus it
should be reasonably easy - what am I missing?

Alternatively, perhaps there's something clever that I can do on the
server side to "short circuit" subsequent postbacks?

Thanks,

Al Cohen

Nov 18 '05 #2
A
Hi,
a solution that allways works, even if the user presses F5, or disables
javascript

I normaly insert a database value (ID, Identity) in a hidden form, when the
"updating" or other stuff takes place, it first checks if the value (ID) is
in the database, if it is there updating takes place and the ID is deleted,
if it is NOT there i tell the user that their data is allready saved,
problerly because they hit the submit button twice...

Regards,

Agge

"Rick Strahl [MVP]" <ri********@hotmail.com> skrev i en meddelelse
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Al,

I've had that same issue. Usually you have to attach the script code to the form's OnSubmit().

Actually what I found is that if you disable the button that you're binding events to the button's event doesn't fire because the button doesn't show up in the post variable list. Hiding the button actually works better.

I usually do this in the HTML but you should be able to do the same with
attributes:

<form id="frmOrderForm"
onsubmit="this.btnSubmit.style.display='none';docu ment.getElementById('WaitN ote').style.display='inline';return true;" ... >

This code hides the button and shows an area that has a message.

Works real well, except that I have an animated Gif in there and it doesn't animate - some bug in IE related to a hidden image not animating, it works
with Mozilla...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Al Cohen" <am***@no.junk.c-o-r-n-e-l-l.edu> wrote in message
news:DM********************@speakeasy.net...
I'm using a LinkButton to call some code, then do a redirect. The code
does some queries, sends some emails, and takes a few moments before the
redirect is performed.

I'd like to disable my LinkButton during this period to prevent multiple
submissions. (Obviously) the disabling should be done at the client
side to prevent any delay. I've tried adding some javascript to
LinkButton.Attributes:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'"
+ this.GetPostBackEventReference(this.LinkButton1));

but this doesn't disable the LinkButton. I also tried:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'");

which disables the link, but never does the postback.

This seems like a very important thing to be able to do, and thus it
should be reasonably easy - what am I missing?

Alternatively, perhaps there's something clever that I can do on the
server side to "short circuit" subsequent postbacks?

Thanks,

Al Cohen


Nov 18 '05 #3
Yes that is good practice. I think a more general approach should be taken
to this sort of thing, where your code should set something right away that
in teh DB that lets it know that the process has already started.

But I still think from a UI perspective it's smart to use something on the
client side to disable the button.

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"A" <ne**@agge.dk> wrote in message
news:ee**************@TK2MSFTNGP12.phx.gbl...
Hi,
a solution that allways works, even if the user presses F5, or disables
javascript

I normaly insert a database value (ID, Identity) in a hidden form, when the "updating" or other stuff takes place, it first checks if the value (ID) is in the database, if it is there updating takes place and the ID is deleted, if it is NOT there i tell the user that their data is allready saved,
problerly because they hit the submit button twice...

Regards,

Agge

"Rick Strahl [MVP]" <ri********@hotmail.com> skrev i en meddelelse
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Al,

I've had that same issue. Usually you have to attach the script code to the
form's OnSubmit().

Actually what I found is that if you disable the button that you're

binding
events to the button's event doesn't fire because the button doesn't show up
in the post variable list. Hiding the button actually works better.

I usually do this in the HTML but you should be able to do the same with
attributes:

<form id="frmOrderForm"

onsubmit="this.btnSubmit.style.display='none';docu ment.getElementById('WaitN ote').style.display='inline';return true;" ... >

This code hides the button and shows an area that has a message.

Works real well, except that I have an animated Gif in there and it

doesn't
animate - some bug in IE related to a hidden image not animating, it works with Mozilla...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Al Cohen" <am***@no.junk.c-o-r-n-e-l-l.edu> wrote in message
news:DM********************@speakeasy.net...
I'm using a LinkButton to call some code, then do a redirect. The code does some queries, sends some emails, and takes a few moments before the redirect is performed.

I'd like to disable my LinkButton during this period to prevent multiple submissions. (Obviously) the disabling should be done at the client
side to prevent any delay. I've tried adding some javascript to
LinkButton.Attributes:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'"
+ this.GetPostBackEventReference(this.LinkButton1));

but this doesn't disable the LinkButton. I also tried:

LinkButton1.Attributes.Add("onclick", "this.href='javascript:void(0)'");
which disables the link, but never does the postback.

This seems like a very important thing to be able to do, and thus it
should be reasonably easy - what am I missing?

Alternatively, perhaps there's something clever that I can do on the
server side to "short circuit" subsequent postbacks?

Thanks,

Al Cohen



Nov 18 '05 #4
How can I stop the linkbutton at a step, and then makes it go on to he
next step????

Nov 19 '05 #5
I dont really understand what you are trying to ask, but as far as I can
guess, you want to disable a link button without postback?
Here is something I did long time ago, I put the linkbutton in a div tag and
used javascript to show and hide it without postback..
Does this suite ur situation?
Hth...
R. Thomas

"Mr.Joe" wrote:
How can I stop the linkbutton at a step, and then makes it go on to he
next step????

Nov 19 '05 #6
please elaborate your question. It is very unclear.

"Mr.Joe" <yo***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
How can I stop the linkbutton at a step, and then makes it go on to he
next step????

Nov 19 '05 #7

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

Similar topics

4
by: sef | last post by:
i have a server-side script that executes this: linkbutton1.Attributes.Add("onClick", "linkClicked();"); the client-side code has an html image control <img id="image1"> the client-side...
2
by: Dave | last post by:
Hi, I have a datagrid with a Templated column below. I want to execute some javascript before the postback to show a hidden "div" tag with static message of "Please Wait..." since the query takes...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
3
by: Rob Meade | last post by:
Hi all, I have a bit of code that programmatically adds some table cells/rows to a table. The last cell adds a LinkButton control, I call it like this: ...
2
by: Fluxray | last post by:
--Background: I have a webform including a datagrid. The datagrid is using template. Its ItemTemplate is used to display a look-up-table with labels. its EditItemTemplate is used to edit a row in...
10
by: Vi | last post by:
Hi, I'm trying to dinamically add LinkButton Controls to a web form. I do something like: for(i=1;i<=someVariable;i++) { LinkButton PageLink = new LinkButton(); PageLink.CommandName =...
1
by: geronimi | last post by:
I want to create a linkbutton in a cell because not every row needs one (so I can't setup a linkbuttoncolumn instead of a boundcolumn.) First, i create a linkbutton in the datagrid_ItemDataBound...
13
by: rn5a | last post by:
In a shopping cart app, suppose a user has placed 5 orders, I want to show him 5 LinkButtons (one for each order) so that when he clicks the first LinkButton, he would be shown the details of his...
14
by: darrel | last post by:
Is it possible to pre-empt the javascript function used to do a postback from a linkbutton? I'd like to use linkbutton to delete a record and want to add a confirmation box via javascript "are...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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.