if not page.ispostback then
'Display confirmation dialog box
btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure?')){}else{return false}")
end if
The code looks good. It does use javascript, which is the only way to interactively ask a question without a post back. That's usually OK since most users have javascript enabled (and ASP.NET generally depends on javascript to be on to run the __doPostBack()
function)
--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
Here is my take on using popups, especially for confirmation.
I strongly am against the use of popups. They are annoying and insulting to the user and an easy excuse for a coder to be lazy at the expense of building a better user interface. "Are you sure...?" If I wasn't sure, I wouldn't
have clicked the button. Think of pop-ups in terms of a car. Would you like it if your car asked you if you were sure each time you performed an action? "Are you sure you want to park? Are you sure you want to start the car? Are you sure you want to apply
the breaks? Are you sure you want to open the door? Are you sure you want to turn left?" Already you can see how annoying this is. So, why build them into your apps? If accidental deletion is a concern, then think of this: 99.9% of the time, the user deletes
stuff because they mean to. For that other .01% you should create a recycle bin so data can be easily restored in that event. So, the jest of this is to build better user interfaces. I think everyone could benefit from reading
About Face 2.0 and
The Inmates Are Running the Asylum by Alan Cooper. After all, it is about creating software that people will enjoy using, not hate using. Sorry if
it sounds a little harsh, but this is the reality of popups.
If they click OK then the button event happens otherwise it does not. SO the code in the event executes if they click OK.
Another way to have an alert popup...
If you use a template for the button, you can simply add a client-side script that will display a confirmation dialog. You can use the new onClientClick attribute:
In the onClientClick property type in "return confirm("Delete row?");" without the double quotes but include the semicolon
Here is my take on using popups, especially for confirmation.
I strongly am against the use of popups. They are annoying and insulting to the user and an easy excuse for a coder to be lazy at the expense of building a better user interface. "Are you sure...?" If I wasn't sure, I wouldn't
have clicked the button. Think of pop-ups in terms of a car. Would you like it if your car asked you if you were sure each time you performed an action? "Are you sure you want to park? Are you sure you want to start the car? Are you sure you want to apply
the breaks? Are you sure you want to open the door? Are you sure you want to turn left?" Already you can see how annoying this is. So, why build them into your apps? If accidental deletion is a concern, then think of this: 99.9% of the time, the user deletes
stuff because they mean to. For that other .01% you should create a recycle bin so data can be easily restored in that event. So, the jest of this is to build better user interfaces. I think everyone could benefit from reading
About Face 2.0 and
The Inmates Are Running the Asylum by Alan Cooper. After all, it is about creating software that people will enjoy using, not hate using. Sorry if
it sounds a little harsh, but this is the reality of popups.
so you argue that if you accidently click "delete" it should just go ahead and delete what you clicked?
sorry, to me that is a faulty system. i don't know how many times confirmation windows have saved me from deleting or messing up important things.
so you argue that if you accidently click "delete" it should just go ahead and delete what you clicked?
sorry, to me that is a faulty system. i don't know how many times confirmation windows have saved me from deleting or messing up important things.
There should always be an eject button. To remedy this, I build a recycle bin in my applications. All deleted data shows up in the recycle bin where it can be purged or restored. Just as if you were to throw away a piece of
paper, you always have the option of retrieving it from the trash if you need it before taking out the trash where it awaits to be picked up and then disposed of at the city dump. However, if you do build popup confirmations into your UI, the user should have
the option to turn them off.
That's assuming you have items or a data source with the functionality to handle "recycled" items. Deleting files from a file system, I can see having a recycle area as that's not that hard to accomplish with alternate directories. What about records in
a database? Adding an archived column to indicated deleted or not is easy enough when you're building an app from the ground up. What about an application that's in production, with tons of queries, stored procs, classes, objects, etc.? Confirmation on
deletes saves support issues and also your own time in having to do a restore if you dont have recycle functionality.
craigbtx
Participant
1702 Points
897 Posts
Adding an Alert box to a button without javascript
Jan 07, 2006 12:33 PM|LINK
if not page.ispostback then
'Display confirmation dialog box
btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure?')){}else{return false}")
end if
PLBlum
All-Star
30399 Points
5347 Posts
MVP
Re: Adding an Alert box to a button without javascript
Jan 07, 2006 04:18 PM|LINK
What is your question?
The code looks good. It does use javascript, which is the only way to interactively ask a question without a post back. That's usually OK since most users have javascript enabled (and ASP.NET generally depends on javascript to be on to run the __doPostBack() function)
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
craigbtx
Participant
1702 Points
897 Posts
Re: Adding an Alert box to a button without javascript
Jan 07, 2006 08:39 PM|LINK
smiling4ever
All-Star
15825 Points
3123 Posts
Re: Adding an Alert box to a button without javascript
Jan 07, 2006 09:06 PM|LINK
I think this thread should be moved to FAQ - Frequently Asked Questions
Right?
Regards
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: Adding an Alert box to a button without javascript
Jan 08, 2006 12:19 AM|LINK
This post has been moved to FAQ.
Here is my take on using popups, especially for confirmation. I strongly am against the use of popups. They are annoying and insulting to the user and an easy excuse for a coder to be lazy at the expense of building a better user interface. "Are you sure...?" If I wasn't sure, I wouldn't have clicked the button. Think of pop-ups in terms of a car. Would you like it if your car asked you if you were sure each time you performed an action? "Are you sure you want to park? Are you sure you want to start the car? Are you sure you want to apply the breaks? Are you sure you want to open the door? Are you sure you want to turn left?" Already you can see how annoying this is. So, why build them into your apps? If accidental deletion is a concern, then think of this: 99.9% of the time, the user deletes stuff because they mean to. For that other .01% you should create a recycle bin so data can be easily restored in that event. So, the jest of this is to build better user interfaces. I think everyone could benefit from reading About Face 2.0 and The Inmates Are Running the Asylum by Alan Cooper. After all, it is about creating software that people will enjoy using, not hate using. Sorry if it sounds a little harsh, but this is the reality of popups.
dhana
Member
5 Points
1 Post
Re: Adding an Alert box to a button without javascript
Jan 09, 2006 08:36 AM|LINK
sir,
Have a great time for me to look at this code and its fine working and i am very thankful to u
but there might be some problem to use this code
the problem is how the event response when we click the ok button, and there might be some action takes place when we click ok
will u help me ?
thanking u
craigbtx
Participant
1702 Points
897 Posts
Re: Adding an Alert box to a button without javascript
Jan 09, 2006 12:00 PM|LINK
If they click OK then the button event happens otherwise it does not. SO the code in the event executes if they click OK.
Another way to have an alert popup...
If you use a template for the button, you can simply add a client-side script that will display a confirmation dialog. You can use the new onClientClick attribute:
In the onClientClick property type in "return confirm("Delete row?");" without the double quotes but include the semicolon
onClientClick='return confirm("Delete row?");
Harold.NET
Contributor
2231 Points
458 Posts
Re: Adding an Alert box to a button without javascript
Jan 17, 2006 04:28 PM|LINK
so you argue that if you accidently click "delete" it should just go ahead and delete what you clicked?
sorry, to me that is a faulty system. i don't know how many times confirmation windows have saved me from deleting or messing up important things.
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: Adding an Alert box to a button without javascript
Jan 17, 2006 04:43 PM|LINK
There should always be an eject button. To remedy this, I build a recycle bin in my applications. All deleted data shows up in the recycle bin where it can be purged or restored. Just as if you were to throw away a piece of paper, you always have the option of retrieving it from the trash if you need it before taking out the trash where it awaits to be picked up and then disposed of at the city dump. However, if you do build popup confirmations into your UI, the user should have the option to turn them off.
darth21
Member
175 Points
35 Posts
Re: Adding an Alert box to a button without javascript
Jan 17, 2006 08:59 PM|LINK