# Thursday, January 31, 2008
Thursday, January 31, 2008 4:32:13 PM (GMT Standard Time, UTC+00:00) ( .Net General | Asp.Net )
this wasn't very obvious to work out, and i couldn't find a decent solution online, so i came up with this.
this.DropDownList1.Attributes.Add("onchange", "if(!confirm('Are you sure you want to delete this item?')) return;");
This works with .Net 2 and 3 and 3.5, but may break with future versions if .Net changes the javascript code for AutoPostBack drop down lists.  The reason it works now is because .Net adds the custom 'onchange' attribute before it's on doPostBack() function call.  So if we return from the confirm prompt, the form will not submit. 

Comments [0] | | # 
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview