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. want to run a script on page load

want to run a script on page load

Scheduled Pinned Locked Moved ASP.NET
toolsquestion
2 Posts 2 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.
  • S Offline
    S Offline
    sanjubaba
    wrote on last edited by
    #1

    hi, i want to run a script on page load. the page is included in a masterpage contentplace holder. eg.

    obj=(document.all) ? document.all\['<%=pnlOptPro.ClientID %>'\] : document.getElementById('<%=pnlOptPro.ClientID %>');
    
    obj.style.display=(obj.style.display=='none') ? 'inline' : 'none';
    
    obj1=(document.all) ? document.all\['<%=pnlUsrwise.ClientID %>'\] : document.getElementById('<%=pnlUsrwise.ClientID %>');
    
    obj1.style.display=(obj1.style.display=='none') ? 'inline' : 'none';
    

    the code which is in the script has to be run when this page is loaded. but this does not happen??

    M 1 Reply Last reply
    0
    • S sanjubaba

      hi, i want to run a script on page load. the page is included in a masterpage contentplace holder. eg.

      obj=(document.all) ? document.all\['<%=pnlOptPro.ClientID %>'\] : document.getElementById('<%=pnlOptPro.ClientID %>');
      
      obj.style.display=(obj.style.display=='none') ? 'inline' : 'none';
      
      obj1=(document.all) ? document.all\['<%=pnlUsrwise.ClientID %>'\] : document.getElementById('<%=pnlUsrwise.ClientID %>');
      
      obj1.style.display=(obj1.style.display=='none') ? 'inline' : 'none';
      

      the code which is in the script has to be run when this page is loaded. but this does not happen??

      M Offline
      M Offline
      Mark J Miller
      wrote on last edited by
      #2

      Try writing it as a function and registering it with the body onload event. More likely than not the script is running but the page hasn't finished loading yet.

      Mark's blog: developMENTALmadness.blogspot.com

      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