User prompt handling

T

Thrud

I have a button (runat=server) with some VB code attached
to its on click event which does data updates.

I now want to add a warning to the user prompting them
whether they really want to perform the update. If they
say Ok then the update proceeds, otherwise it is cancelled.

How is the best way to do this? As far as I see the only
way to get the prompt is to use the JScript Confirm
function but to use this I need to turn off the
runat=server flag which makes the button disappear.

Any help would be much appreciated, Thrud
 
C

Curt_C [MVP]

couple ways...
First is a simple CLIENT-SIDE confirm attached to the button.
The other is what I have done. Two buttons. The first simply posts back and
"un-hides" a confirm button while it "hides" the save button. The confirm
button has the actual code to save the info to the DB, not the save button.
 
M

Munsifali Rashid

Use:

MyButton.Attributes.Add("onClick", "return confirm('Are you sure you want to
continue with this update?')")

Hope this helps,

Mun
 
K

Kikoz

Add this to your button in code behind:

btn.Attributes["onClick"] = "alert('Something');"

Or "confirm" - same thing, but use return.

Regards.
 
T

Thrud

Thanks All, especially Munsifali,

MyButton.Attributes.Add("onClick", "return confirm('Are
you sure you want to
continue with this update?')")

works exactly how I want.
 

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,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top