开发者

ScriptManager is not declared - err msg

I've this class and it gave me an error name 'ScriptManager is not declared'

Public NotInheritable Class ResponseHelper
Private Sub New()
End Sub
Public Shared Sub Redirect(ByVal response As HttpResponse, ByVal url As String, ByVal target As String, ByVal windowFeatures As String)
    If ([String].IsNullOrEmpty(target) OrElse target.Equals("_self", StringComparison.OrdinalIgnoreCase)) AndAlso [String].IsNullOrEmpty(windowFeatures) Then
        response.Redirect(url)
    Else
        Dim page As Page = DirectCast(HttpContext.Current.Handler, Page)
        If page Is Nothing Then
            Throw New InvalidOperationException("Cannot redirect to new window outside Page context.")
        End If
        url = page.ResolveClientUrl(url)
        Dim script As String
        If Not [String].IsNullOrEmpty(windowFeatures) Then
            script = "window.open(""{0}"", ""{1}"", ""{2}"");"
        Else
            script = "window.open(""{0}"", ""{1}"");"
        End If
        script = [String].Format(script, url, target, windowFeatures)
        Sc开发者_JS百科riptManager.RegisterStartupScript(page, GetType(Page), "Redirect", script, True)
    End If
End Sub 

End Class

This code from this link:

http://weblogs.asp.net/infinitiesloop/archive/2007/09/25/response-redirect-into-a-new-window-with-extension-methods.aspx

I've been 8 hours trying to figure out how to open a new page and send parameters to it. And found this code , and 6 hours trying to apply it but nothing.

Thanks.


You need Ajax to be installed to access the Scriptmanager. Use Page.ClientScript.RegisterStartupScript instead. If you want a solution that works whether AJAX is available or not, have a look at this link.


Try put the full name space before scirptmananger, System.UI.Web.ScriptManager.RegisterStartupScript(...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜