Disabling button control event.

P

peli

Hi,,

I want to disable a button control event after first clicked.
The reason is that when the button is clicked, a dataset which holds data
accesses database to save data.
If button is clicked twice, the same data is stored twice. Therefore I want
to disable the button immediately after a client clicked.

Does anyone know about this?
Would you teach me?

Thanks.

peliz
 
A

Alessandro Zifiglio

YOu cant disable the button like that.
Peliz, maybe i should have said this earlier but if you dont plan to use
that custom control then you might just want to wrap your code within an if
block checking against a session variable or viewstate on whether it is
already set and if false to execute the code and set the viewstate this way
subsequent clicks will fail
like :
if (ViewState("FirstRound") is nothing) then
'execute code and insert/update/delete from db
'after successfull execution set the viewstate
viewstate("FirstRound") = "OK"
else
'code already been executed so do something else or do nothing at all ;)
response.redirect("nextpage.aspx")
End if

or place the logic in your stored proc, that is check to see if the record
has already been added/deleted/updated and if so do nothing, this should be
fairly easy to achieve ;)

The stuff with the viewstate I havent really tested, its off the top of my
head but makes sense so give it a shot ;)
 
A

Alessandro Zifiglio

YOu cant disable the button like that.
Peliz, maybe i should have said this earlier but if you dont plan to use
that custom control then you might just want to wrap your code within an if
block checking against a session variable or viewstate on whether it is
already set and if false to execute the code and set the viewstate this way
subsequent clicks will fail
like :
if (ViewState("FirstRound") is nothing) then
'execute code and insert/update/delete from db
'after successfull execution set the viewstate
viewstate("FirstRound") = "OK"
else
'code already been executed so do something else or do nothing at all ;)
response.redirect("nextpage.aspx")
End if

or place the logic in your stored proc, that is check to see if the record
has already been added/deleted/updated and if so do nothing, this should be
fairly easy to achieve ;)

The stuff with the viewstate I havent really tested, its off the top of my
head but makes sense so give it a shot ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top