[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Shawn

1/23/2003 5:21:00 PM

I have a VBScript for the popup message box as following

<SCRIPT LANGUAGE="VBScript">
<!-- Instruct non-IE browsers to skip over VBScript modules.
'Option Explicit
Sub cmdDelete_OnClick
If MsgBox("Are you sure you want to delete the record?", _
MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
MsgBoxStyle.YesNo, _
"Confirm Deletion") = MsgBoxResult.Yes Then ' User chose Yes.
' Perform some action.
Else
' Perform some other action.
End If
End Sub
-->
</SCRIPT>

It doesn't work well. When I click the cmdDelete button, it show me the
followin error:
Error: Object required: 'MsgBoxStyle'

I am new in VBScript. Is there any one who can help me fix it? I assume the
default focus is No button in the message box.

Thanks.





8 Answers

Pedro Martins

1/23/2003 5:52:00 PM

0

On another note entirely, MessageBoxes won't work in ASP.NET. You need to
use javascript's alert function.

Jim

"Shawn" <x_zz@yahoo.com> wrote in message
news:#biNntvwCHA.2504@TK2MSFTNGP10...
> I have a VBScript for the popup message box as following
>
> <SCRIPT LANGUAGE="VBScript">
> <!-- Instruct non-IE browsers to skip over VBScript modules.
> 'Option Explicit
> Sub cmdDelete_OnClick
> If MsgBox("Are you sure you want to delete the record?", _
> MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
> MsgBoxStyle.YesNo, _
> "Confirm Deletion") = MsgBoxResult.Yes Then ' User chose Yes.
> ' Perform some action.
> Else
> ' Perform some other action.
> End If
> End Sub
> -->
> </SCRIPT>
>
> It doesn't work well. When I click the cmdDelete button, it show me the
> followin error:
> Error: Object required: 'MsgBoxStyle'
>
> I am new in VBScript. Is there any one who can help me fix it? I assume
the
> default focus is No button in the message box.
>
> Thanks.
>
>
>
>
>


Mark

1/23/2003 5:54:00 PM

0

Shawn,

I'd recommend simplifying some of your code a bit to make it a bit easier to
read and debug ...

dim vbResponse
vbResponse = MsgBox("Are you sure you want to delete the record?", vbYesNo
+ vbCritical, "My Title")

if (vbResponse = vbYes) Then
' Perform some action.
msgbox ("Delete me")
Else
' Perform some other action.
msgbox ("Delete aborted")
End If

Hope that helps.
Mark
www.dovetaildatabases.com

"Shawn" <x_zz@yahoo.com> wrote in message
news:#biNntvwCHA.2504@TK2MSFTNGP10...
> I have a VBScript for the popup message box as following
>
> <SCRIPT LANGUAGE="VBScript">
> <!-- Instruct non-IE browsers to skip over VBScript modules.
> 'Option Explicit
> Sub cmdDelete_OnClick
> If MsgBox("Are you sure you want to delete the record?", _
> MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
> MsgBoxStyle.YesNo, _
> "Confirm Deletion") = MsgBoxResult.Yes Then ' User chose Yes.
> ' Perform some action.
> Else
> ' Perform some other action.
> End If
> End Sub
> -->
> </SCRIPT>
>
> It doesn't work well. When I click the cmdDelete button, it show me the
> followin error:
> Error: Object required: 'MsgBoxStyle'
>
> I am new in VBScript. Is there any one who can help me fix it? I assume
the
> default focus is No button in the message box.
>
> Thanks.
>
>
>
>
>


Kevin Spencer

1/23/2003 5:56:00 PM

0

First of all, you should be using JavaScript, unless you're absolutely sure
that no non-IE browsers will be hosting your HTML. In other words, your
VBScript function will not fire in non-IE browsers.

Second, you're trying to put in constant values into your function call, and
the client browser has no definitions for these constant tokens (e.g.
"msgBoxStyle.Critical" etc). Instead, put in the literal values of these
constants, or the VBScript constants, such as

MyVar = MsgBox ("Hello World!", vbDefaultButton2 + vbYesNo + vbCritical,
"MsgBox Example")

HTH,

--
Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.ta...
Big things are made up of lots of little things.


"Shawn" <x_zz@yahoo.com> wrote in message
news:#biNntvwCHA.2504@TK2MSFTNGP10...
> I have a VBScript for the popup message box as following
>
> <SCRIPT LANGUAGE="VBScript">
> <!-- Instruct non-IE browsers to skip over VBScript modules.
> 'Option Explicit
> Sub cmdDelete_OnClick
> If MsgBox("Are you sure you want to delete the record?", _
> MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
> MsgBoxStyle.YesNo, _
> "Confirm Deletion") = MsgBoxResult.Yes Then ' User chose Yes.
> ' Perform some action.
> Else
> ' Perform some other action.
> End If
> End Sub
> -->
> </SCRIPT>
>
> It doesn't work well. When I click the cmdDelete button, it show me the
> followin error:
> Error: Object required: 'MsgBoxStyle'
>
> I am new in VBScript. Is there any one who can help me fix it? I assume
the
> default focus is No button in the message box.
>
> Thanks.
>
>
>
>
>


Shawn

1/23/2003 6:54:00 PM

0

Kevin. You are absolutely right. But I want to set the default focus to No,
instead of Yes, Can I do it for Confirm dialog in Javascript? I dont like to
use showModalDialog to simulate the window effect, though.

"Kevin Spencer" <kevin@takempis.com> wrote in message
news:O92Nw#vwCHA.2504@TK2MSFTNGP10...
> First of all, you should be using JavaScript, unless you're absolutely
sure
> that no non-IE browsers will be hosting your HTML. In other words, your
> VBScript function will not fire in non-IE browsers.
>
> Second, you're trying to put in constant values into your function call,
and
> the client browser has no definitions for these constant tokens (e.g.
> "msgBoxStyle.Critical" etc). Instead, put in the literal values of these
> constants, or the VBScript constants, such as
>
> MyVar = MsgBox ("Hello World!", vbDefaultButton2 + vbYesNo + vbCritical,
> "MsgBox Example")
>
> HTH,
>
> --
> Kevin Spencer
> Microsoft FrontPage MVP
> Internet Developer
> http://www.ta...
> Big things are made up of lots of little things.
>
>
> "Shawn" <x_zz@yahoo.com> wrote in message
> news:#biNntvwCHA.2504@TK2MSFTNGP10...
> > I have a VBScript for the popup message box as following
> >
> > <SCRIPT LANGUAGE="VBScript">
> > <!-- Instruct non-IE browsers to skip over VBScript modules.
> > 'Option Explicit
> > Sub cmdDelete_OnClick
> > If MsgBox("Are you sure you want to delete the record?", _
> > MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
> > MsgBoxStyle.YesNo, _
> > "Confirm Deletion") = MsgBoxResult.Yes Then ' User chose
Yes.
> > ' Perform some action.
> > Else
> > ' Perform some other action.
> > End If
> > End Sub
> > -->
> > </SCRIPT>
> >
> > It doesn't work well. When I click the cmdDelete button, it show me the
> > followin error:
> > Error: Object required: 'MsgBoxStyle'
> >
> > I am new in VBScript. Is there any one who can help me fix it? I assume
> the
> > default focus is No button in the message box.
> >
> > Thanks.
> >
> >
> >
> >
> >
>
>


Shawn

1/23/2003 6:56:00 PM

0

Thanks a lot. It is working!


"Mark" <field027@umn.edu> wrote in message
news:uz4IpAwwCHA.2680@TK2MSFTNGP09...
> Shawn,
>
> I'd recommend simplifying some of your code a bit to make it a bit easier
to
> read and debug ...
>
> dim vbResponse
> vbResponse = MsgBox("Are you sure you want to delete the record?",
vbYesNo
> + vbCritical, "My Title")
>
> if (vbResponse = vbYes) Then
> ' Perform some action.
> msgbox ("Delete me")
> Else
> ' Perform some other action.
> msgbox ("Delete aborted")
> End If
>
> Hope that helps.
> Mark
> www.dovetaildatabases.com
>
> "Shawn" <x_zz@yahoo.com> wrote in message
> news:#biNntvwCHA.2504@TK2MSFTNGP10...
> > I have a VBScript for the popup message box as following
> >
> > <SCRIPT LANGUAGE="VBScript">
> > <!-- Instruct non-IE browsers to skip over VBScript modules.
> > 'Option Explicit
> > Sub cmdDelete_OnClick
> > If MsgBox("Are you sure you want to delete the record?", _
> > MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
> > MsgBoxStyle.YesNo, _
> > "Confirm Deletion") = MsgBoxResult.Yes Then ' User chose
Yes.
> > ' Perform some action.
> > Else
> > ' Perform some other action.
> > End If
> > End Sub
> > -->
> > </SCRIPT>
> >
> > It doesn't work well. When I click the cmdDelete button, it show me the
> > followin error:
> > Error: Object required: 'MsgBoxStyle'
> >
> > I am new in VBScript. Is there any one who can help me fix it? I assume
> the
> > default focus is No button in the message box.
> >
> > Thanks.
> >
> >
> >
> >
> >
>
>


Kevin Spencer

1/23/2003 7:14:00 PM

0

Unfortunately, in JavaScript, your options are fewer. You would use the
JavaScript confirm() function, which takes only a single argument, which is
the message to display. It produces a Message Box with an Ok and Cancel
button, and returns True or False. You can't set the default button.

HTH,

--
Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.ta...
Big things are made up of lots of little things.

"Shawn" <x_zz@yahoo.com> wrote in message
news:uX3pyhwwCHA.428@TK2MSFTNGP09...
> Kevin. You are absolutely right. But I want to set the default focus to
No,
> instead of Yes, Can I do it for Confirm dialog in Javascript? I dont like
to
> use showModalDialog to simulate the window effect, though.
>
> "Kevin Spencer" <kevin@takempis.com> wrote in message
> news:O92Nw#vwCHA.2504@TK2MSFTNGP10...
> > First of all, you should be using JavaScript, unless you're absolutely
> sure
> > that no non-IE browsers will be hosting your HTML. In other words, your
> > VBScript function will not fire in non-IE browsers.
> >
> > Second, you're trying to put in constant values into your function call,
> and
> > the client browser has no definitions for these constant tokens (e.g.
> > "msgBoxStyle.Critical" etc). Instead, put in the literal values of these
> > constants, or the VBScript constants, such as
> >
> > MyVar = MsgBox ("Hello World!", vbDefaultButton2 + vbYesNo + vbCritical,
> > "MsgBox Example")
> >
> > HTH,
> >
> > --
> > Kevin Spencer
> > Microsoft FrontPage MVP
> > Internet Developer
> > http://www.ta...
> > Big things are made up of lots of little things.
> >
> >
> > "Shawn" <x_zz@yahoo.com> wrote in message
> > news:#biNntvwCHA.2504@TK2MSFTNGP10...
> > > I have a VBScript for the popup message box as following
> > >
> > > <SCRIPT LANGUAGE="VBScript">
> > > <!-- Instruct non-IE browsers to skip over VBScript modules.
> > > 'Option Explicit
> > > Sub cmdDelete_OnClick
> > > If MsgBox("Are you sure you want to delete the record?", _
> > > MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
> > > MsgBoxStyle.YesNo, _
> > > "Confirm Deletion") = MsgBoxResult.Yes Then ' User chose
> Yes.
> > > ' Perform some action.
> > > Else
> > > ' Perform some other action.
> > > End If
> > > End Sub
> > > -->
> > > </SCRIPT>
> > >
> > > It doesn't work well. When I click the cmdDelete button, it show me
the
> > > followin error:
> > > Error: Object required: 'MsgBoxStyle'
> > >
> > > I am new in VBScript. Is there any one who can help me fix it? I
assume
> > the
> > > default focus is No button in the message box.
> > >
> > > Thanks.
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>


Steve C. Orr, MCSD

1/23/2003 8:35:00 PM

0

It seems he was referring to client side VBScript, in which case MsgBox will
work (assuming an IE client of course.) Of course the syntax is a bit
different than the VB.NET MessageBox function that is more for windows forms
applications.

--
I hope this helps,
Steve C. Orr, MCSD
http://Ste...


"Jim Baker" <NOSPAM@NOSPAM.ORG> wrote in message
news:ufVFW$vwCHA.2680@TK2MSFTNGP09...
> On another note entirely, MessageBoxes won't work in ASP.NET. You need to
> use javascript's alert function.
>
> Jim
>
> "Shawn" <x_zz@yahoo.com> wrote in message
> news:#biNntvwCHA.2504@TK2MSFTNGP10...
> > I have a VBScript for the popup message box as following
> >
> > <SCRIPT LANGUAGE="VBScript">
> > <!-- Instruct non-IE browsers to skip over VBScript modules.
> > 'Option Explicit
> > Sub cmdDelete_OnClick
> > If MsgBox("Are you sure you want to delete the record?", _
> > MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
> > MsgBoxStyle.YesNo, _
> > "Confirm Deletion") = MsgBoxResult.Yes Then ' User chose
Yes.
> > ' Perform some action.
> > Else
> > ' Perform some other action.
> > End If
> > End Sub
> > -->
> > </SCRIPT>
> >
> > It doesn't work well. When I click the cmdDelete button, it show me the
> > followin error:
> > Error: Object required: 'MsgBoxStyle'
> >
> > I am new in VBScript. Is there any one who can help me fix it? I assume
> the
> > default focus is No button in the message box.
> >
> > Thanks.
> >
> >
> >
> >
> >
>
>


ZhouJiexing

1/24/2003 2:49:00 AM

0

in an asp.net page, if you want to popup a dialog,please
use MessageBox WebControl instead of MsgBox(VBScript)
method or alert(javascript) method.

MessageBox WebControl enables you popup a dialog in your
asp.net page. The dialog popuped can show the user a
message, or ask the user a yes/no question, or ask user to
input a string, or show the user your customized htmlpage.

Please view http://www.jttz.com/msgbox... for the
detail.