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. Help regarding master pages

Help regarding master pages

Scheduled Pinned Locked Moved ASP.NET
questionjavascripthelp
7 Posts 3 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
    anu81
    wrote on last edited by
    #1

    hi all, I have a master page which includes some javascript code to get the current mouse position. i have 2 aspx pages which uses this master page and i need to use the javascript defined in master page in my two aspx pages. How can i call them?

    Thanks in advance.:) Regards Anuradha

    I 1 Reply Last reply
    0
    • A anu81

      hi all, I have a master page which includes some javascript code to get the current mouse position. i have 2 aspx pages which uses this master page and i need to use the javascript defined in master page in my two aspx pages. How can i call them?

      Thanks in advance.:) Regards Anuradha

      I Offline
      I Offline
      Imran Khan Pathan
      wrote on last edited by
      #2

      call javascript onmouseover event of body of master page. for example

      bEst rEgard
      pAthan

      please don't forget to vote on the post that helped you.

      A 1 Reply Last reply
      0
      • I Imran Khan Pathan

        call javascript onmouseover event of body of master page. for example

        bEst rEgard
        pAthan

        please don't forget to vote on the post that helped you.

        A Offline
        A Offline
        anu81
        wrote on last edited by
        #3

        hi, thanks for your help. i used the following code function getX(evt) { if (document.all) { return (evt.clientX); } return (evt.layerX); } function getY(evt) { if (document.all) { return (evt.clientY); } return (evt.layerY); } function getScrollX() { if (document.all) { return (document.body.scrollLeft); } return (window.pageXOffset); } function getScrollY() { if (document.all) { return (document.body.scrollTop); } return (window.pageYOffset); } function showValues(e) { var posx = 0; var posy = 0; posx= getX(e) + getScrollX(); posy= getY(e) + getScrollY(); } and called the function showValues(event) in mousemove event of the body of master page as u described. i need to use the variables posx and posy in my content pages. How can it be done???

        Thanks Regards Anuradha

        N 1 Reply Last reply
        0
        • A anu81

          hi, thanks for your help. i used the following code function getX(evt) { if (document.all) { return (evt.clientX); } return (evt.layerX); } function getY(evt) { if (document.all) { return (evt.clientY); } return (evt.layerY); } function getScrollX() { if (document.all) { return (document.body.scrollLeft); } return (window.pageXOffset); } function getScrollY() { if (document.all) { return (document.body.scrollTop); } return (window.pageYOffset); } function showValues(e) { var posx = 0; var posy = 0; posx= getX(e) + getScrollX(); posy= getY(e) + getScrollY(); } and called the function showValues(event) in mousemove event of the body of master page as u described. i need to use the variables posx and posy in my content pages. How can it be done???

          Thanks Regards Anuradha

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          anu81 wrote:

          i need to use the variables posx and posy in my content pages.

          Why ? After rendering and showing the page to the browser, there is no separation like Master/Content page. All will be rendered to produce a single page. So whatever client side script you are writing on Master/Content page will be in same page after rendering. So what's your problem ?


          My Website | Ask smart questions

          A 1 Reply Last reply
          0
          • N N a v a n e e t h

            anu81 wrote:

            i need to use the variables posx and posy in my content pages.

            Why ? After rendering and showing the page to the browser, there is no separation like Master/Content page. All will be rendered to produce a single page. So whatever client side script you are writing on Master/Content page will be in same page after rendering. So what's your problem ?


            My Website | Ask smart questions

            A Offline
            A Offline
            anu81
            wrote on last edited by
            #5

            hi, thanks for your reply. i too thought the same that the entire page is rendered and there is no difference between master and content page. But when i access the values posx and posy in a javascript function from the content page like this, function fnZoomImage(comment_text) { oDiv = document.getElementById('idPOPUP'); if (oDiv != null) window.document.body.removeChild(oDiv); oDiv = window.document.createElement("DIV"); oDiv.style.position="absolute"; oDiv.style.visibility = "visible"; oDiv.style.padding = "1px"; oDiv.style.width = "0px"; oDiv.style.height = "0px"; oDiv.style.border = "0px"; oDiv.style.left = posx + "px"; oDiv.style.top = posy + "px"; oDiv.id = "idPOPUP"; oDiv.innerHTML = ""+ ""+ " "+ ""+ "

            "+ " " + comment_text + "

            "; window.document.body.appendChild(oDiv); } i get a error saying posx is undefined.

            Thanks Regards Anuradha

            N 1 Reply Last reply
            0
            • A anu81

              hi, thanks for your reply. i too thought the same that the entire page is rendered and there is no difference between master and content page. But when i access the values posx and posy in a javascript function from the content page like this, function fnZoomImage(comment_text) { oDiv = document.getElementById('idPOPUP'); if (oDiv != null) window.document.body.removeChild(oDiv); oDiv = window.document.createElement("DIV"); oDiv.style.position="absolute"; oDiv.style.visibility = "visible"; oDiv.style.padding = "1px"; oDiv.style.width = "0px"; oDiv.style.height = "0px"; oDiv.style.border = "0px"; oDiv.style.left = posx + "px"; oDiv.style.top = posy + "px"; oDiv.id = "idPOPUP"; oDiv.innerHTML = ""+ ""+ " "+ ""+ "

              "+ " " + comment_text + "

              "; window.document.body.appendChild(oDiv); } i get a error saying posx is undefined.

              Thanks Regards Anuradha

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              anu81 wrote:

              i get a error saying posx is undefined.

              Your script is a mess. Variable posx is declared inside a function, and you are accessing that from another function. This is not possible because variable posx scope ends when the first function ends. So how you can access it here ? Try making posx declare outside the function. But I am not sure that you can access variables declared on different script blocks. If it's not working put a hidden textbox and assign the posx value there. Then read from this hidden textbox in the content page and assign to another variable.


              My Website | Ask smart questions

              A 1 Reply Last reply
              0
              • N N a v a n e e t h

                anu81 wrote:

                i get a error saying posx is undefined.

                Your script is a mess. Variable posx is declared inside a function, and you are accessing that from another function. This is not possible because variable posx scope ends when the first function ends. So how you can access it here ? Try making posx declare outside the function. But I am not sure that you can access variables declared on different script blocks. If it's not working put a hidden textbox and assign the posx value there. Then read from this hidden textbox in the content page and assign to another variable.


                My Website | Ask smart questions

                A Offline
                A Offline
                anu81
                wrote on last edited by
                #7

                hi, oh ya.i did not notice that. sorry for the inconvinience. thanks for your suggestions. I will try it out.

                Thanks Regards Anuradha

                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