Results 1 to 5 of 5

Thread: javascript confirm message

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    javascript confirm message

    BtnAddRec.Attributes.Add("onclick", "javascript:return confirm('Message Here')")

    I'm using this code in the btnAddRec click event, but it's not giving me the message. Is this correct?

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    if you put that in the click event of btnAddRec, you'll have to hit the button twice for it to work. Put it in the page_load and it'll work first time out.

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    I can't put it in the page load event because the button is from inside a datagrid. Is there something else I can do to get the message box to show?


    Code:
     Public Sub DeleteBid(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
            'check which row has been selected
            Dim selectedRow As String = DataGrid1.DataKeys(e.Item.ItemIndex)
            Dim btnDelete As Button
            btnDelete = e.Item.Cells(4).Controls(0) '<---5th column, first control 
            btnDelete.Attributes("onclick") = "javascript:return confirm('Are you sure you want to delete \n    Bid Record " & selectedRow & "?')"
    Last edited by EyeTalion; Jan 6th, 2003 at 03:09 PM.

  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Add it to the 'ItemDataBound' event handler for the datagrid. This event fires evertime an item is bound to a datasource.

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    I placed it in the itemDataBound event. I'm getting an "Index out of range error" because no row has been selected yet....

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