473,394 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to change VBScript to VB code behind file

Hi,

I need a pop-up window for user to confirm change. The default button is the
second option (No). As the user only use IE, I think the VBScript is an
option. The following code only works for html button. I wonder how I can
change it to VB code behind file and use a server control.

Thanks.

<script language="VBScript">
Sub cmdDelete()
Dim vbResponse
vbResponse = MsgBox("are you sure you want to delete?", vbYesNo +
vbCritical+ vbDefaultButton2, "Title")

If vbResponse = vbYes Then
' do something
Else
' Label1.Text = "do not do delete"
End If
End Sub
</script>
Nov 17 '05 #1
5 1729
The only way to do that, is if you controls outputs the javascript you have
there.

VBScript and VB.NET code behind - are not related in any way. The former is
a client side scripting language, while the latter is a server side compiled
language. No relation.

Your VB.NET would have to generated this VBScript code, for it to run.

"Sean" <ss****@yahoo.com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
Hi,

I need a pop-up window for user to confirm change. The default button is the second option (No). As the user only use IE, I think the VBScript is an
option. The following code only works for html button. I wonder how I can
change it to VB code behind file and use a server control.

Thanks.

<script language="VBScript">
Sub cmdDelete()
Dim vbResponse
vbResponse = MsgBox("are you sure you want to delete?", vbYesNo +
vbCritical+ vbDefaultButton2, "Title")

If vbResponse = vbYes Then
' do something
Else
' Label1.Text = "do not do delete"
End If
End Sub
</script>

Nov 17 '05 #2
Marina,

Thanks for your reply.

If I am correct, javascript doesn't allow me to set the default button to
the 2nd option (e.g. No.). If VBScript doesn't work here, in this case, what
option do I have for implementation?

Thanks for your input.

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...
The only way to do that, is if you controls outputs the javascript you have there.

VBScript and VB.NET code behind - are not related in any way. The former is a client side scripting language, while the latter is a server side compiled language. No relation.

Your VB.NET would have to generated this VBScript code, for it to run.

"Sean" <ss****@yahoo.com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
Hi,

I need a pop-up window for user to confirm change. The default button is

the
second option (No). As the user only use IE, I think the VBScript is an
option. The following code only works for html button. I wonder how I can change it to VB code behind file and use a server control.

Thanks.

<script language="VBScript">
Sub cmdDelete()
Dim vbResponse
vbResponse = MsgBox("are you sure you want to delete?", vbYesNo +
vbCritical+ vbDefaultButton2, "Title")

If vbResponse = vbYes Then
' do something
Else
' Label1.Text = "do not do delete"
End If
End Sub
</script>


Nov 17 '05 #3
Cor
Hi Sean,
I used for this example a webform with one textbox and two buttons on it
(named Buttonyes and ButtonNo.)
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = "are you sure you want to delete?"
End Sub

Private Sub ButtonNo_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ButtonNo.Click
TextBox1.Text = "do something"
End Sub

Private Sub Buttonyes_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Buttonyes.Click
TextBox1.Text = "do not delete"
End Sub
See yourself how it works
Cor
Nov 17 '05 #4

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...
The only way to do that, is if you controls outputs the javascript you have there.

VBScript and VB.NET code behind - are not related in any way. The former is a client side scripting language, while the latter is a server side compiled language. No relation.
Well, VBScript is used for ASP, so it's not necessarily used on the client
side.

I think you can reuse that code, only that you have to bind it to the
control/button
that you want to use.


Your VB.NET would have to generated this VBScript code, for it to run.

"Sean" <ss****@yahoo.com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
Hi,

I need a pop-up window for user to confirm change. The default button is

the
second option (No). As the user only use IE, I think the VBScript is an
option. The following code only works for html button. I wonder how I can change it to VB code behind file and use a server control.

Thanks.

<script language="VBScript">
Sub cmdDelete()
Dim vbResponse
vbResponse = MsgBox("are you sure you want to delete?", vbYesNo +
vbCritical+ vbDefaultButton2, "Title")

If vbResponse = vbYes Then
' do something
Else
' Label1.Text = "do not do delete"
End If
End Sub
</script>


Nov 17 '05 #5
How can I bind it to a control/button, then?
I tried Button1.Attributes.Add("onclick", "VBscriptFunctionName();") in
Page_Load, but it is not working either.

Thanks.

"James Zhuo" <na**************@optusnet.com.au> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...
The only way to do that, is if you controls outputs the javascript you have
there.

VBScript and VB.NET code behind - are not related in any way. The former is
a client side scripting language, while the latter is a server side

compiled
language. No relation.


Well, VBScript is used for ASP, so it's not necessarily used on the client
side.

I think you can reuse that code, only that you have to bind it to the
control/button
that you want to use.


Your VB.NET would have to generated this VBScript code, for it to run.

"Sean" <ss****@yahoo.com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
Hi,

I need a pop-up window for user to confirm change. The default button is
the
second option (No). As the user only use IE, I think the VBScript is

an option. The following code only works for html button. I wonder how I

can change it to VB code behind file and use a server control.

Thanks.

<script language="VBScript">
Sub cmdDelete()
Dim vbResponse
vbResponse = MsgBox("are you sure you want to delete?", vbYesNo +
vbCritical+ vbDefaultButton2, "Title")

If vbResponse = vbYes Then
' do something
Else
' Label1.Text = "do not do delete"
End If
End Sub
</script>



Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Sean | last post by:
Hi, I need a pop-up window for user to confirm change. The default button is the second option (No). As the user only use IE, I think the VBScript is an option. The following code only works for...
10
by: Jim Ciotuszynski | last post by:
Is there an equivalent to the "button.attributes.add("onBlur","JavaScript:return somfunction();") ? I thought that vbscrpt would also do the same but when I run my code with the vbscript my...
5
by: ad | last post by:
The Global.asax is code-inside with default. How to change Global.asax to code-behind?
5
by: Drum2001 | last post by:
I have a database that allows the user to input a department code and get all the employees within the department. The table is generated from another script that places the numeric code as a...
0
by: ismailc | last post by:
Good day, I need help. I have an application that uses aspx pages together with vbscript window for developer coding. Now the page has an <input type='file'> upload object. The problem is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.