Message Box functionality in ASP dot net using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ansuiya
    New Member
    • Jan 2007
    • 40

    #1

    Message Box functionality in ASP dot net using javascript

    I am using a delete button in a datagrid control.When ever user presses this button a messate box should appear for confirmation with ok and canel buttons.
    on pressing OK Button record should be deleted and on Pressing Cancel it should not.
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    Originally posted by Ansuiya
    I am using a delete button in a datagrid control.When ever user presses this button a messate box should appear for confirmation with ok and canel buttons.
    on pressing OK Button record should be deleted and on Pressing Cancel it should not.

    Use javascript's confirm("Do you want to delete the selected record ?");

    :)

    Comment

    • Ansuiya
      New Member
      • Jan 2007
      • 40

      #3
      I have used this logic already but how can i send the response back to my asp dot net code behind file.I am using this code.
      [PHP] Public Sub datagrid_delete Command(ByVal source As Object, ByVal e As DataGridCommand EventArgs) Handles DataGrid2.Delet eCommand

      Dim idv1 As New TextBox
      Dim v As Integer
      v = CInt(DataGrid2. DataKeys(e.Item .ItemIndex))

      Response.Write( "<html><bod y onLoad='check() '><script language='javas cript'>var res=confirm('Do you want to delete current record'); function check() {document.form1 .t1.value=res;} </script> <form name='form1'> <input type='hidden' name='t1'></form></body></html> ")

      cmd = New OleDbCommand(" delete from dept where id=" & CInt(v) & "", conn)
      conn.Open()
      cmd.ExecuteNonQ uery()
      conn.Close()
      DataGrid2.EditI temIndex = -1
      rebindgrid()

      End Sub[/PHP]

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Place your JS in a class, here is an example:
        Adding Client-Side Message Boxes in your ASP.NET Web Pages

        Comment

        • radcaesar
          Recognized Expert Contributor
          • Sep 2006
          • 759

          #5
          To use javascript in code behind directly, u have to use Attributes.add( ) method

          :)

          Originally posted by Ansuiya
          I have used this logic already but how can i send the response back to my asp dot net code behind file.I am using this code.
          [PHP] Public Sub datagrid_delete Command(ByVal source As Object, ByVal e As DataGridCommand EventArgs) Handles DataGrid2.Delet eCommand

          Dim idv1 As New TextBox
          Dim v As Integer
          v = CInt(DataGrid2. DataKeys(e.Item .ItemIndex))

          Response.Write( "<html><bod y onLoad='check() '><script language='javas cript'>var res=confirm('Do you want to delete current record'); function check() {document.form1 .t1.value=res;} </script> <form name='form1'> <input type='hidden' name='t1'></form></body></html> ")

          cmd = New OleDbCommand(" delete from dept where id=" & CInt(v) & "", conn)
          conn.Open()
          cmd.ExecuteNonQ uery()
          conn.Close()
          DataGrid2.EditI temIndex = -1
          rebindgrid()

          End Sub[/PHP]

          Comment

          Working...