Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox like Yes/No confirmation asp.net / vb.net.

Status
Not open for further replies.

jjjax64

IS-IT--Management
Apr 27, 2010
39
US
We have a a few button fields in our gridview and we'd like to be able to have it prompt user to confirm before continuing. Seen a couple Javascripts that do it onclick events but would like to do right in vb code if possible. Here is the asp code for one of the buttons in our gridview:

<asp:ButtonField ButtonType="Button" CommandName="Complete"
HeaderText="" ShowHeader="False" Text="Complete" />

And the VB code behind:

Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand

'Would like to do some kind of msgbox to confirm that they want to continue

Dim currentCommand As String = e.CommandName

If currentCommand = "Complete" Then

Dim currentRowIndex As Integer = Int32.Parse(e.CommandArgument

Dim PageID As String = GridView1.Rows(currentRowIndex).Cells(0).Text

Dim connSQL As SqlConnection = New SqlConnection("Initial Catalog=productionx;Data Source=sqlserverx;Integrated Security=False; user id=xxx;password=yyyyyyyy; Connect Timeout=60"

connSQL.Open()

Dim sqlSP As String

sqlSP = "exec spWebCircularCustomerCompleteTemplate @PageID =" & PageID

Dim cmdSP As New SqlCommand(sqlSP, connSQL)

Dim rdrSP As SqlDataReader = cmdSP.ExecuteReader()

rdrSP.Read()

rdrSP.Close()

connSQL.Close()

Response.Redirect("../Circulars/EditCircularPage.aspx")

End If

End Sub

Thanks,
Joe
 
Seen a couple Javascripts that do it onclick events but would like to do right in vb code if possible.
can't be done. that's the nature of web development. the client and server are physically separate boxes. all the client understands is html, css and js. the server is where .net is running.

therefore to prompt the user with a confirmation box you will need to use javascript. this could be as simple as a confirmation box, ugly, but it works
Code:
return confirm('are you sure you want to remove this record');
or you can present the user with a custom dialog box like jquery's dialog

Jason Meckley
Senior Programmer

faq855-7190
faq732-7259
My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top