User prompt handling

  • Thread starter Thread starter Thrud
  • Start date Start date
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
 
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.
 
Use:

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

Hope this helps,

Mun
 
Add this to your button in code behind:

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

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

Regards.
 
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.
 
Back
Top