Apply ScriptManager in global module or global class

Last post 08-06-2009 5:16 AM by Kusno. 4 replies.

Sort Posts:

  • Apply ScriptManager in global module or global class

    08-03-2009, 4:36 AM
    • Member
      12 point Member
    • Kusno
    • Member since 04-05-2007, 5:51 AM
    • Somewhere between heaven and hell
    • Posts 49

    Dear all,

    How do I apply ScriptManager.RegisterStartupScript in global module or global class?. I want show javaScript Alert

    It always raises an error like this:

    Compilation Error
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
    
    Compiler Error Message: BC30451: Name 'ScriptManager' is not declared.
    
    Public Sub ShowMsgBox(ByVal Msg As String)
            Dim Pg As Page = HttpContext.Current.Handler
            If Not Pg Is Nothing Then
                Msg = Msg.Replace("'", "\'")
                ScriptManager.RegisterClientScriptBlock(Pg, Pg.GetType(), "msg", "alert('" & Msg & "')", True)
            End If
    End Sub
    




    It's confusing me, I run it well from MS. Visual Studio 2005 But after I copied it into our server, Windows 20003 it rose an error like that.
    I have already installed AJAX.Net Framework in our server.


    Thanks for the advance

    Never Never Never Give Up !!
  • Re: Apply ScriptManager in global module or global class

    08-03-2009, 6:14 AM
    Answer

    Use the following code:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            Dim someScript As String = ""
            someScript = "<script language='javascript'>alert('Called from CodeBehind');</script>"
            Page.ClientScript.RegisterStartupScript(Me.GetType(), "onload", someScript)
        End Sub
    Saurabh Nijhawan(B.Tech. CSE,GGSIPU,New Delhi)
    Application Architect, Eminent Solutions, New Delhi.
    Freelancer | Teacher
    Remember to click "Mark as Answer" on the post, if it helped you.
    ASP.NET Weblog
    http://www.saurabhnijhawan.com
    Learning Made Easy

    There's nothing more than to be Alive, think twice before you kill or are a reason for an Animal's killing..
    Against Animal Killing
  • Re: Apply ScriptManager in global module or global class

    08-03-2009, 6:25 AM
    Answer
    • Contributor
      3,816 point Contributor
    • fayaz_3e
    • Member since 09-14-2007, 10:15 AM
    • Hyderabad
    • Posts 806

    Hi,

    'ScriptManager' is not declared means you are not referring to the related namespace. ScriptManager is a member of System.Web.UI.  Refer this namespace in your class file.

    Fayaz
  • Re: Apply ScriptManager in global module or global class

    08-05-2009, 1:42 AM
    Answer

     Hi,

    Please put your code in a vb class file, and add "Import System.Web.UI" as refference.


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Apply ScriptManager in global module or global class

    08-06-2009, 5:16 AM
    • Member
      12 point Member
    • Kusno
    • Member since 04-05-2007, 5:51 AM
    • Somewhere between heaven and hell
    • Posts 49

    Solved..there were wrong web config configurations actually. Thanks a lot guys

    Never Never Never Give Up !!
Page 1 of 1 (5 items)