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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. JavaScript registering at PageLoad for User Control

JavaScript registering at PageLoad for User Control

Scheduled Pinned Locked Moved ASP.NET
javascripttoolshelp
6 Posts 3 Posters 1 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.
  • M Offline
    M Offline
    mark_me
    wrote on last edited by
    #1

    Hi, I have a tab strip (telerik), with 3 tabs. Each tab strip opens a separate Web Control. When i add javascript to first control's (pageload) on the first tab, the javascript works but when i add it in second or 3rd tab (user control page load),javascript doesnot render to page. (i cant see it in ViewSource) Please note that i cannot add javascript in the designer for page so am adding the script at runtime on page load. The javascript also works when added in Parent Page. It only doesnt work in 2nd,3rd tab controls. It starts working from 3rd tab when added on parent or first tab control. (and i am not allowed to add anything outside this 3rd tab control) My code for script is

    dim script as string = " function Check(){alert('hello');}"
    Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),"mycustomScript",script,false)

    Also i have tried RegisterStartupScript. The controls contains Ajax (RadControls) and script manager is added to parent page.The Manager Proxy is added to each page separately. Please provide help in this regard Best Regards haseeb

    P B 2 Replies Last reply
    0
    • M mark_me

      Hi, I have a tab strip (telerik), with 3 tabs. Each tab strip opens a separate Web Control. When i add javascript to first control's (pageload) on the first tab, the javascript works but when i add it in second or 3rd tab (user control page load),javascript doesnot render to page. (i cant see it in ViewSource) Please note that i cannot add javascript in the designer for page so am adding the script at runtime on page load. The javascript also works when added in Parent Page. It only doesnt work in 2nd,3rd tab controls. It starts working from 3rd tab when added on parent or first tab control. (and i am not allowed to add anything outside this 3rd tab control) My code for script is

      dim script as string = " function Check(){alert('hello');}"
      Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),"mycustomScript",script,false)

      Also i have tried RegisterStartupScript. The controls contains Ajax (RadControls) and script manager is added to parent page.The Manager Proxy is added to each page separately. Please provide help in this regard Best Regards haseeb

      P Offline
      P Offline
      Pranay Rana
      wrote on last edited by
      #2

      Try this ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);

      1 Reply Last reply
      0
      • M mark_me

        Hi, I have a tab strip (telerik), with 3 tabs. Each tab strip opens a separate Web Control. When i add javascript to first control's (pageload) on the first tab, the javascript works but when i add it in second or 3rd tab (user control page load),javascript doesnot render to page. (i cant see it in ViewSource) Please note that i cannot add javascript in the designer for page so am adding the script at runtime on page load. The javascript also works when added in Parent Page. It only doesnt work in 2nd,3rd tab controls. It starts working from 3rd tab when added on parent or first tab control. (and i am not allowed to add anything outside this 3rd tab control) My code for script is

        dim script as string = " function Check(){alert('hello');}"
        Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),"mycustomScript",script,false)

        Also i have tried RegisterStartupScript. The controls contains Ajax (RadControls) and script manager is added to parent page.The Manager Proxy is added to each page separately. Please provide help in this regard Best Regards haseeb

        B Offline
        B Offline
        Brij
        wrote on last edited by
        #3

        Use scriptmanager to register the script,It is required when we use ajax on the page.

        Cheers!! Brij

        P M 2 Replies Last reply
        0
        • B Brij

          Use scriptmanager to register the script,It is required when we use ajax on the page.

          Cheers!! Brij

          P Offline
          P Offline
          Pranay Rana
          wrote on last edited by
          #4

          ok sorry i thought he used rad control with the scriptmanager control of ajax toolkist

          1 Reply Last reply
          0
          • B Brij

            Use scriptmanager to register the script,It is required when we use ajax on the page.

            Cheers!! Brij

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

            hi, thanx for ur reply... if u mean to use something like this dim cs as scriptmanager = page.clientscript cs.RegisterClientScript(args) then this also doesn't work. otherwise can u please provide a sample code... Thanks ,

            B 1 Reply Last reply
            0
            • M mark_me

              hi, thanx for ur reply... if u mean to use something like this dim cs as scriptmanager = page.clientscript cs.RegisterClientScript(args) then this also doesn't work. otherwise can u please provide a sample code... Thanks ,

              B Offline
              B Offline
              Brij
              wrote on last edited by
              #6

              When we use ajax on our page a scriptmanager class is found on the aspx.cs page and then we use this class to register the script.The code will be like below.

              ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), this.ClientID, "ShowMessage();", true);

              Cheers!! Brij

              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