problem with clientscriptmanager
hi guy,
I want to create a popup window in my asp application & be able to pass parameters to that new window. I've found some code on another message board which should do the trick, except i'm having problems compiling it.
Private Sub PopupForm()
Dim nWindow As String = "NewWindowScript"
Dim cstype As Type = Me.GetType()
Dim csm As ClientScriptManager = Page.ClientScript
' Check to see if this script is already registered.
If (Not csm.IsClientScriptBlockRegistered(cstype, nWindow)) Then
Dim scriptText As New StringBuilder
scriptText.Append("<script type=text/javascript> function OpenNewWindow(nw,param) {")
scriptText.Append("window.open(nw+param,null,'heig ht=450,width=450,status=no,")
scriptText.Append("resizable=yes,scrollbars=no,too lbar=yes,location=yes,menubar=no');}")
scriptText.Append("</script>")
csm.RegisterClientScriptBlock(cstype, nWindow, scriptText.ToString(), False)
End If
'declare two variables (you can get this information elsewhere though)
Dim pageName, param As String
pageName = "default.aspx?ID="
param = "SomeIdValue"
'add an attribute to your label (or other control) and pass
'in the pagename and a value. These are then accepted
'in the function we previously decalred (added to the page) and
'used to open a new window with parameters.
lblCheckAttribute.Attributes.Add("onclick", "OpenNewWindow('" & pageName & "','" & param & "');")
End Sub
---------------------------------------------------------
The error message it gives is : "Type 'ClientScriptManager' is not defined."
I've tried using the import statement "imports system.web.ui", but it still gives me the error. Can anyone please help me out?
thanks,
mark
|