(c) 2002 Visual Studio Magazine 
Fawcette Technical Publications

Issue: July 2002
Section: ASP.NET
Author: Ken Cox

VB.NET	This Code Fires as the ASP.NET Page Loads
Listing 1	The code checks the value of IsPostBack and generates the client-side script for a pop-up window when IsPostBack is false. The calls to the StringBuilder Append method build the JavaScript that the RegisterStartupScript inserts into the HTML stream.

Private Sub Page_Load _
	(ByVal sender As System.Object, ByVal _
	e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
	Dim sb As New System.Text.StringBuilder()
	sb.Append("<script ")
	sb.Append("language='javascript'>")
	sb.Append("window.open('poll.aspx',")
	sb.Append("'poll','toolbar=no,")
	sb.Append("addressbar=no,menubar=no,")
	sb.Append("width=300,height=300');")
	sb.Append("</script>")
	Button1.Text = "Welcome to our site!"
	RegisterStartupScript("stp", sb.ToString)
Else
	Button1.Text = "Welcome back!"
 
End If
End Sub
