Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

help, simple messagebox w VBscript

In an aspx.vb file If I do the following w/ Javascript it works, but not with VBscript

Partial Class _Default
Inherits System.Web.UI.Page

Private Sub MessageBox(ByVal msg As String)
' define a javascript alertbox containing
' the string passed in as argument

' create a new label
Dim lbl As New Label()

' add the javascript to fire an alertbox to the label and
' add the string argument passed to the subroutine as the
' message payload for the alertbox
lbl.Text = "<script language='*****either "javascript" or "VBscript"**'>" & Environment.NewLine & _
"alert('" + msg + "')</script>"

' add the label to the page to display the alertbox
Page.Controls.Add(lbl)
End Sub

Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
MessageBox("Hello")
End Sub

End Class


Little technical details like these (where it's hard to find examples to this level of details in VB.net 2.0 w/ VBscript) have been driving me nuts. If someone is willing to check their email or this forum every so often today (til midnight California time), I'm willing to pay a reasonable tutoring fee.
[1453 byte] By [tristanolas] at [2007-11-11 9:59:37]
# 1 Re: help, simple messagebox w VBscript
Try this:

Option Strict On
Option Explicit On

Partial Class _Default
Inherits System.Web.UI.Page

Private Sub MessageBox(ByVal msg As String)
Dim script As String = "<script language=""vbscript"">window.alert(""" & msg & """)</script>"
ClientScript.RegisterStartupScript(Me.GetType, "alert", script)
End Sub

Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
MessageBox("Hello")
End Sub

End Class
Phil Weber at 2007-11-11 23:12:10 >
# 2 Re: help, simple messagebox w VBscript
Thanks that worked fine. Now I just need to figure out how to attach my other VBscripts. There are so many little details that determine the exact syntax that it's hard to narrow down information / web searches to this.
tristanolas at 2007-11-11 23:13:18 >