C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Confirm Delete Box in DataGrid Delete Button


Posted Date: 06 Jul 2006    Resource Type: Articles    Category: Web Applications
Author: Pritam BaldotaMember Level: Gold    
Rating: Points: 5



Confirm Message Box before Deleting





Scenarion I



To use confirm Message box before delete operation uses JavaScript for confirmation box. You have to add JavaScript on button.

Page_Load

if(!IsPostBack) btnConfirm.Attributes.Add("onclick","return confirm('Do you want to Delete');");

Once clicked Ok button on Confirm Box it executes Button_Click server event else doesn’t do anything.

btnConfirm_Click

//Your server code to delete


Scenario II



The DataList and DataGrid controls easily allow to add a "Delete" button/hyperlink in your template. When clicked, this button/link raises a DeleteCommand event that you can handle to delete the data item.










DataGrid’s Template Delete Button raises DeleteCommand event after clicking Delete Button of DataGrid. We needs to write javascript confirm method to this template button. This should be write in DataGrid’s ItemCreated event because it fires when datagrid’s item has been created.


private void dg_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{

//Check for Item and Alternate Items if(e.Item.ItemType==ListItemType.AlternatingItem || e.Item.ItemType==ListItemType.Item)
{
Button btn=(Button)e.Item.Cells[0].Controls[0];
btn.Attributes.Add("onclick","return confirm(‘Do you want to continue?’);");
}

}



Summary







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Wonders with Javascript
Previous Resource: The secret of ASP.NET 2.0 mobile pages
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use