By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,461 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Add Confirm Box to Select button

P: 29
Hi, i would like to ask if it is possible to add confirm box to the select button. I wish to add a confirm box to my code below, pls help...Thank in advance.
Expand|Select|Wrap|Line Numbers
  1. Sub CustomersGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
  2.  
  3.         Dim row As GridViewRow = GridView1.SelectedRow
  4.         Dim str As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("database\db1.mdb")
  5.         Dim conn As New OleDbConnection(str)
  6.  
  7.         If row.Cells(2).Text = "" Then
  8.             Dim mySelectQuery As String = "SELECT State, FileID FROM Table3"
  9.  
  10.             Dim myUpdateQuery As String = "Update Table3 Set State='6' where FileID=" & "'" & row.Cells(1).Text & "'" & ""
  11.  
  12.             Dim myConnection As New OleDbConnection(str)
  13.  
  14.             Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
  15.  
  16.             Dim myCommand2 As New OleDbCommand(myUpdateQuery, myConnection)
  17.  
  18.             Dim retvalue As Integer
  19.  
  20.             myConnection.Open()
  21.  
  22.             myCommand2.ExecuteNonQuery()
  23.  
  24.             Console.WriteLine(retvalue)
  25.  
  26.             Dim myReader As OleDbDataReader
  27.  
  28.             myReader = myCommand.ExecuteReader()
  29.  
  30.  
  31.             While myReader.Read <> 0
  32.  
  33.                 Label1.Text = ("Successfully Approve")
  34.  
  35.  
  36.             End While
  37.             myReader.Close()
  38.  
  39.  
  40.             myConnection.Close()
  41.  
  42.         End If
  43.  
Apr 23 '07 #1
Share this Question
Share on Google+
1 Reply


Frinavale
Expert Mod 5K+
P: 9,731
Hi there,

I don't see a "select button" in this code.

I'm assuming that you are implementing a web application
You can add JavaScript to a button so that when the user clicks it, a confirm box shows up:
Expand|Select|Wrap|Line Numbers
  1. BTN_Select.Attributes.Add("onclick", "javascript:" + "if(confirm('Are you sure you'd like to select?')==true) {document.getElementById('__Reset').value=True;})
  2.  
You have to make sure that you've registered the hidden form variable "__Reset" so that the JavaScript works properly.
Expand|Select|Wrap|Line Numbers
  1. ClientScript.RegisterHiddenField("__Reset","False")
Then you'll have to check this hidden field's value in your code to see if the Select Button's logic should be done or not.

Hope this helps

-Frinny
Apr 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.