Results 1 to 2 of 2

Thread: javascript alert incorporating with asp code-behind

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 1999
    Location
    Westfield, IN, USA
    Posts
    59

    javascript alert incorporating with asp code-behind

    I have a function in an asp.net page that will delete a record from a database. I need to have a message pop up to confirm deletion. I have searched google and everywhere for about 2 hours now, hoping to find something.

    It looks like everyone is saying i need javascript or vbscript to pop open the alert. However i'm unable to figure out how i can have a button on my asp.net page have the onClick event equal a javascript and then have the "OK" on the javascript popup call the asp.net function for deletion.

    Does anyone know how i can do this?

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Here is the code I wrote that I use with the datagrid:

    Code:
    private void grdBooks_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    	if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer)
    	{
    		LinkButton delete = (LinkButton)e.Item.Cells[e.Item.Cells.Count-1].Controls[0];
    		delete.Attributes["onclick"] ="javascript:return confirm('Are you sure you want to delete " 
    			+ DataBinder.Eval(e.Item.DataItem, "Title") + "?')";   
    	}		
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width