Register | Login
Saturday, September 06, 2008

Sections
  
About Us
  
Hosting Provided by Server Intellect
Partners
Downloads
  
 WWWCoder.com Resource Directory

Adding a Confirmation to Delete Options in IBuySpy
8/6/2003 12:42:57 PM

I don't know about you, but I can't count how many times when I first installed IBS, about how a content editor deleted something by mistake, because they clicked on the delete icon next to item in IBS. One thing lacking in IBS is a confirmation from the application whether or not you want to delete an item.

I don't know about you, but I can't count how many times when I first installed IBS, about how a content editor deleted something by mistake, because they clicked on the delete icon next to item in IBS. One thing lacking in IBS is a confirmation from the application whether or not you want to delete an item.



Figure 1: Tabs Section of IBS


As in figure when a person goes to delete a tab in IBS, no warning will be issued, it will just delete the tab. From the layout of IBS, the icons for moving, editing, and deleting are pretty close together. You can see how someone can inadvertently delete and item from there. What we need to accomplish is the functionality to allow a person to back out of deleting and item in case they clicked on the wrong button. In this example we will be modifying the TabLayout.aspx.vb file to add a bit of Javascript behind the button.


If you open the TabLayout.aspx.vb file and look for the Page_Load method, we're going to add the following code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles MyBase.Load
' Verify that the current user has access to access this page
If PortalSecurity.IsInRoles("Admins") = False Then
Response.Redirect("~/Admin/EditAccessDenied.aspx")
End If

' Determine Tab to Edit
If Not (Request.Params("tabid") Is Nothing) Then
tabId = Int32.Parse(Request.Params("tabid"))
End If

' If first visit to the page, update all entries
If Page.IsPostBack = False Then
' Now add the modified code for the delete confirmation.
LeftDeleteBtn.Attributes.Add("onClick", _
"javascript:return confirm('Are You Sure You Wish To Delete This Item ?');")
RightDeleteBtn.Attributes.Add("onClick", _
"javascript:return confirm('Are You Sure You Wish To Delete This Item ?');")
ContentDeleteBtn.Attributes.Add("onClick", _
"javascript:return confirm('Are You Sure You Wish To Delete This Item ?');")
BindData()
End If
End Sub


The code above should then add a Javascript confirmation to your image button, in the following way:



So now if the user decides to cancel the delete it will still be there. No more calls to you to restore the database.


 

By: Patrick Santry, Microsoft MVP (ASP/ASP.NET), developer of this site, author of books on Web technologies, and member of the DotNetNuke core development team. If you're interested in the services provided by Patrick, visit his company Website at Santry.com.


Page Options:
format for printing  Format for Printer
email article  Email Page
add to your favorites   Add to Favorites
How would you rate the quality of this content?
Poor - - Excellent
Comments?
Overall Rating:
Comments Left:
Left on 4/1/2006 1:07:36 AM by Anonymous
Comments: Is there a simple way to restore all my inquiries to Appleseeds.com on 3/31/06.  I deleted a response to the company by mistake.  Restoration is my goal.
Left on 1/15/2005 12:52:22 PM by Anonymous
Comments: Kinda obvious.  Would have been more of a contribution if the confirmations were actual pages, not just a dialog box.
Left on 7/10/2004 1:19:36 AM by Anonymous
Comments: needs to longer and clearer
Left on 8/22/2003 3:42:49 AM by Anonymous
Comments: just what I needed
  

 Latest Articles
  

 Latest News
  

 

Spotlight
Syndication

 


 


Digg This
 


DotNetNuke Platinum Benefactor

  
 

 Terms Of Use | Privacy Statement
 Copyright 2008 - Santry Technology Solutions, Box 172, Girard, PA 16417, (814) 774-0970