© 2002 Visual Studio Magazine
Fawcette Technical Publications
Issue: July 2002
Section: ASP.NET
Author: Ken Cox
Filename: vs0207an
Readme file for Implement Client Scripts article.
This source code incorporates the snippets used in the article.
For easiest use in VS.NET, create a new VB Web application called vsm and drop these files into it. Build and browse each file.
Note that when viewing within the VS.NET environment, secondary windows will continue to display inside the IDE. For best results, view the pages using Internet Explorer.
The table below shows the snippets and the corresponding filename in which that code will be found.
Ken Cox
Toronto
March/2002
|
Snippet |
Filename |
|
Private
Sub Page_Load _ (ByVal sender As System.Object, ByVal
_ e As System.EventArgs) _ Handles MyBase.Load RegisterOnSubmitStatement("submit",
_ "return confirm('Delete "
& _ Label2.Text & "?');") End
Sub |
confirm.aspx.vb |
|
Private
Sub Page_Load _ (ByVal
sender As System.Object, ByVal _ e As System.EventArgs) _ Handles MyBase.Load Dim sb
As New _ System.Text.StringBuilder() sb.Append("<script
language=") sb.Append("javascript>")
sb.Append("function
setchkbx(){") sb.Append("document.forms[0]")
sb.Append(".dd.disabled=")
sb.Append("(document.forms[0]")
sb.Append(".pc[0].checked==")
sb.Append("true);}</script>")
RegisterClientScriptBlock("cs",
_ sb.ToString) End
Sub |
block.aspx.vb |
|
Private
Sub Page_Load _ (ByVal
sender As System.Object, ByVal _ e As System.EventArgs) _ Handles MyBase.Load RegisterClientScriptBlock
_ ("library", "<script
src='" & _ "library.js'></script>") End
Sub |
incllib.aspx.vb |
|
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!" RegisterStartupScript("stp",
"") End If
End
Sub |
popup.aspx.vb |
|
Private
Sub Page_Load _ (ByVal
sender As System.Object, ByVal _ e As System.EventArgs) _ Handles MyBase.Load ImgB1.Attributes.Add
_ ("onMouseOver", _ "this.src='flgov.gif';") ImgB1.Attributes.Add
_ ("onMouseOut", _ "this.src='flgnm.gif';") ImgB1.Attributes.Add
_ ("src",
"flgnm.gif") End
Sub |
addattribute.aspx.vb |
|
Private
Sub Button1_Click _ (ByVal
sender As System.Object, ByVal _ e As System.EventArgs) _ Handles Button1.Click RadioButtonList1.Visible
= False Label1.Text
= "Thanks for voting." Button1.Text
= "Close" Button1.Attributes.Add("onclick",
_ "window.close();") End
Sub |
poll.aspx.vb |