...

View Full Version : Prompt confirmation after button click



shaoen01
01-10-2006, 06:34 PM
I wish to add an attribute to the button click in asp.net to prompt a confirmation box using javascript. Also, is it possible to perform a function after a button click before i prompt the confirmation box? This function will return a value indicating whether i should prompt the confirmation box.

I know i should add a code as shown below but it does not work somehow:


btnDelete.Attributes.Add("onClick", "javascript:return confirm('Are you sure you want to delete these rows?')")


Thanks

vinyl-junkie
01-11-2006, 02:58 AM
Here (http://aspnet.4guysfromrolla.com/articles/021104-1.aspx) is an article that walks you through exactly how to do that. Hope it helps.

shaoen01
01-13-2006, 07:42 AM
I tried the coding but it does not work for my webform with other coding. But if i create a new webform, it will work. Not sure why though ...

vinyl-junkie
01-14-2006, 01:26 AM
I don't know how you're building your applications, but if you're using Visual Studio to do them, and the "are you sure" file is a code-behind file, Visual Studio builds the .dll file for it automatically. If you do an Add Existing Item within Visual Studio to an existing application, Visual Studio should still build the .dll file for you.

OTOH, if you're not using Visual Studio, you may have to build the .dll file yourself for the "are you sure" file and put it in your root directory.

If none of the above applies, then I'm as puzzled as you are.

Brandoe85
01-14-2006, 01:56 AM
I tried the coding but it does not work for my webform with other coding. But if i create a new webform, it will work. Not sure why though ...

Post your code so we can take a look at it.

shaoen01
01-23-2006, 05:59 PM
Sorry for late reply, didnt know that you have submitted a new post. Anyway, i know why it does not work, because in my asp.net i included a onclick function in javascript for the same button causing it not to work.

I now use that onclick function javascript to prompt for me the confirmation box. Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum