Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ClientScript.RegisterStartupScript Problem

ClientScript.RegisterStartupScript Problem

Scheduled Pinned Locked Moved ASP.NET
helpjavascripttools
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndyCapp
    wrote on last edited by
    #1

    I have the following line of code string script = " document.location = '#cv'; "; Page.ClientScript.RegisterStartupScript(GetType(String), "goToError", script.ToString()); All it does is register a javascript routine for client side scripting. All the examples that I have looked at have exactly the same way of invoking the RegisterStartupScript method, however when I try and compile my code I receive a "'string' is a 'type' but is used like a 'variable'" Error message. I have tried string and String, however all sample that I have seen use the String, What am I doing wrong that I cannot get my code to compile. This is the only compilation error message that I receive. Thanks in advance Andy Carpe Diem -- modified at 4:25 Tuesday 11th April, 2006

    P C M 3 Replies Last reply
    0
    • A AndyCapp

      I have the following line of code string script = " document.location = '#cv'; "; Page.ClientScript.RegisterStartupScript(GetType(String), "goToError", script.ToString()); All it does is register a javascript routine for client side scripting. All the examples that I have looked at have exactly the same way of invoking the RegisterStartupScript method, however when I try and compile my code I receive a "'string' is a 'type' but is used like a 'variable'" Error message. I have tried string and String, however all sample that I have seen use the String, What am I doing wrong that I cannot get my code to compile. This is the only compilation error message that I receive. Thanks in advance Andy Carpe Diem -- modified at 4:25 Tuesday 11th April, 2006

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #2

      you could always try replacing String with this

      1 Reply Last reply
      0
      • A AndyCapp

        I have the following line of code string script = " document.location = '#cv'; "; Page.ClientScript.RegisterStartupScript(GetType(String), "goToError", script.ToString()); All it does is register a javascript routine for client side scripting. All the examples that I have looked at have exactly the same way of invoking the RegisterStartupScript method, however when I try and compile my code I receive a "'string' is a 'type' but is used like a 'variable'" Error message. I have tried string and String, however all sample that I have seen use the String, What am I doing wrong that I cannot get my code to compile. This is the only compilation error message that I receive. Thanks in advance Andy Carpe Diem -- modified at 4:25 Tuesday 11th April, 2006

        C Offline
        C Offline
        che_needs
        wrote on last edited by
        #3

        Hi As i far as i have used Page.RegisterStartupScript take 2 parameters one is key value and the other is the script as string. Can you try executing removing gettype(string). cheese

        M 1 Reply Last reply
        0
        • A AndyCapp

          I have the following line of code string script = " document.location = '#cv'; "; Page.ClientScript.RegisterStartupScript(GetType(String), "goToError", script.ToString()); All it does is register a javascript routine for client side scripting. All the examples that I have looked at have exactly the same way of invoking the RegisterStartupScript method, however when I try and compile my code I receive a "'string' is a 'type' but is used like a 'variable'" Error message. I have tried string and String, however all sample that I have seen use the String, What am I doing wrong that I cannot get my code to compile. This is the only compilation error message that I receive. Thanks in advance Andy Carpe Diem -- modified at 4:25 Tuesday 11th April, 2006

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          The GetType method takes a string object like "String", not the type String as the method parameter. If you use the type, you may use the typeof operator instead.

          A 1 Reply Last reply
          0
          • C che_needs

            Hi As i far as i have used Page.RegisterStartupScript take 2 parameters one is key value and the other is the script as string. Can you try executing removing gettype(string). cheese

            M Offline
            M Offline
            minhpc_bk
            wrote on last edited by
            #5

            The .Net 2.0 introduces a new class called ClientScriptManager that supports the RegisterStartupScript[^] with 3 parameters. And you can access this object using the ClientScript property of the Page instance.

            1 Reply Last reply
            0
            • M minhpc_bk

              The GetType method takes a string object like "String", not the type String as the method parameter. If you use the type, you may use the typeof operator instead.

              A Offline
              A Offline
              AndyCapp
              wrote on last edited by
              #6

              Thanks for the help, so I understand that it should be RegisterStartupScript(typeof(String), param2, param3) Or RegisterStartupScript(GetType("String"), param2, param3) instead of RegisterStartupScript(GetType(String), param2, param3) Appreciate the help Andy Carpe Diem

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups