Hi Norman,
A sample of my code is below, appreciate your help thanks!
"Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Dim Response As MsgBoxResult
Response = MsgBox("Do You Want To Delete This User?", 131108,
"Confirm User Deletion")
If Response = MsgBoxResult.Yes Then
SqlCommandUserDelete.Parameters("@UserNo").Value = TextBox5.Text
SqlCommandUserDelete.Connection.Open()
SqlCommandUserDelete.ExecuteNonQuery()
SqlCommandUserDelete.Connection.Close()
...."
> If it runs as WEB app on your computer (Your browser->IIS->your browser) and
> the messagebox pops up inside browser, there is not reason it would not work
[quoted text clipped - 27 lines]
> >
> > Can anyone help me out on this? Many thanks in advance!!!
Norman Yuan - 14 Jun 2005 04:25 GMT
Obviously, you used MsgBox of Windows App style. Web app is a server/client
type app that is significantly different from Window app. The
Button5_Click() runs at web server side (as I previously pointed out, the
server is beyond of user's reach and user cannot see your messagebox show on
the server screen, if there is a screen and if the server allows you to show
messagebox). For a web app, when the Button5_Click() is run, that means user
has already clicked the button and the web page(form) has already been send
to the web server. To display MessageBox like you want, you need client side
code that run by web browser. Common practice is to attach a piece of client
side code (javascript, or other script language the browser can run) to the
"Delete" button. Here is an example:
Private Page_Load(....)
{
if (!Page.IsPostBack)
{
....
Button5.Attributes.Add("onclick","return confirm('Do you really want
to delete this?');");
}
}
The example is in C#, hope you have no problem interpret it into VB.NET. In
ASP.NET, if a web control (button) has client side code attached, if it get
clicked, client side code runs first before the control causes postback. If
the client side code returns "false", the postback will be cancelled.
comfirm() is a standard javasript messagebox function.
You really SHOULD NOT use Miscrosof.VisualBasic namespace in ASP.NET app. It
is meant largely for Windows app and for back compatibility to lure VB6
programmers to .NET platform. I'd suggest to forget it entirely.
> Hi Norman,
>
[quoted text clipped - 43 lines]
> > >
> > > Can anyone help me out on this? Many thanks in advance!!!