[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Message box in ASP.Net with VB.Net

Posted on 2004-11-14
7
Medium Priority
?
4,814 Views
Last Modified: 2013-11-25
Hi,

Im using VB.Net with ASP.Net and when I click a button, i would like a message box to come up with 'Yes' and 'No' before the button does it's action.  But this produces an error.  The code is below:

_____________________________________________________________________________________________

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Create message box
        Dim Msg, style, title, response
        Msg = "Quit BAS Calculator?"
        style = vbYesNo
        title = "System Message"
        response = MsgBox(Msg, style, title)

        If response = vbYes Then
            'Clear all rows corresponding to the rep where e has been set to indicate that the row was edited
            Dim updateCmd As String
            updateCmd = "UPDATE KG_Forecast SET Edit = '' WHERE Rep LIKE '" & Session("UserID") & "'"
            Dim myCommand As SqlCommand
            myCommand = New SqlCommand(updateCmd, myConnection)
            Dim CurrentTextBox As System.Web.UI.WebControls.TextBox
            myCommand.Connection.Open()
            Try
                myCommand.ExecuteNonQuery()
                dgProducts.EditItemIndex = -1
            Catch exp As Exception
                lblMessage.Text = "ERROR: " & exp.Message
            End Try
            myCommand.Connection.Close()

            BindGrid("ID")
        End If
    End Sub
_____________________________________________________________________________________________

Can anyone help???

Thanks in advance,

JK
0
Comment
Question by:jakekula
  • 2
  • 2
5 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 672 total points
ID: 12581575
Hi jakekula,

you have to use javscript to do that. There is a lot stuf on the net
check these articles :
http://aspnet.4guysfromrolla.com/articles/021104-1.aspx ( vb )

http://www.codeproject.com/aspnet/NingLiangSimpleControl.asp
http://p2p.wrox.com/topic.asp?TOPIC_ID=10194



Regards!
B..M
mmarinov
0
 
LVL 2

Assisted Solution

by:dnoxs
dnoxs earned 664 total points
ID: 12581582
To get a messagebox to display use javascript:

If Not IsPostBack Then
    Button1.Attributes.Add("onclick", "javascript:if (confimr('UPDATE?')) { location='smapepage.aspx?action=update'; } else { alert('Not Confirmed'); } ");
End If

Very simple but gives you a quick idea of how you might do it
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12581601
dnoxs,
just a correction - there is a typo :

it is not confimr but confirm function

Regards!
B..M
mmarinov
0
 
LVL 2

Expert Comment

by:dnoxs
ID: 12582036
Thanks! Was in a bit of a hurry!
0
 
LVL 25

Assisted Solution

by:nauman_ahmed
nauman_ahmed earned 664 total points
ID: 12583871
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question