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. Access parent page controls from Iframe [modified]

Access parent page controls from Iframe [modified]

Scheduled Pinned Locked Moved ASP.NET
8 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.
  • R Offline
    R Offline
    rana78
    wrote on last edited by
    #1

    Hi All, Can anybody let me know as to how can one access the parent page controls (textbox control value in my case) from within an iframe. I need to access the textbox control value on the parent page, for some logic impementation in my iframe code behind (.cs ). Can somebody answer me quick. Thanks in Advance, Rana78 -- modified at 10:56 Monday 13th August, 2007

    s k bhuyan

    M N 2 Replies Last reply
    0
    • R rana78

      Hi All, Can anybody let me know as to how can one access the parent page controls (textbox control value in my case) from within an iframe. I need to access the textbox control value on the parent page, for some logic impementation in my iframe code behind (.cs ). Can somebody answer me quick. Thanks in Advance, Rana78 -- modified at 10:56 Monday 13th August, 2007

      s k bhuyan

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      Use "top" keyword for accessing parent page.

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

      R 1 Reply Last reply
      0
      • M Michael Sync

        Use "top" keyword for accessing parent page.

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

        R Offline
        R Offline
        rana78
        wrote on last edited by
        #3

        Michael ,can u please elaborate a little more(how do i use this keyword) more over i'am trying to access the parent page from server side code and not client end javascript ! Thanks, Rana -- modified at 12:04 Monday 13th August, 2007

        Rana78

        M 1 Reply Last reply
        0
        • R rana78

          Hi All, Can anybody let me know as to how can one access the parent page controls (textbox control value in my case) from within an iframe. I need to access the textbox control value on the parent page, for some logic impementation in my iframe code behind (.cs ). Can somebody answer me quick. Thanks in Advance, Rana78 -- modified at 10:56 Monday 13th August, 2007

          s k bhuyan

          N Offline
          N Offline
          Nick cheng liu
          wrote on last edited by
          #4

          You can do it with javascript. For example: add the following code on the child page function Test() { var parentTextBox = parent.document.getElementById("TextBox1"); //TextBox1 is the ID of TextBox on ParentPage. alert(parentTextBox.value); } I am learning english

          M N 2 Replies Last reply
          0
          • R rana78

            Michael ,can u please elaborate a little more(how do i use this keyword) more over i'am trying to access the parent page from server side code and not client end javascript ! Thanks, Rana -- modified at 12:04 Monday 13th August, 2007

            Rana78

            M Offline
            M Offline
            Michael Sync
            wrote on last edited by
            #5

            AFAIK, you can't access the control of parent page from Code-behind. So, you have to use Javascript for accessing the parent page. After that, you have to look a tick to access this client-side value from Code-behind.. For example: There are one textbox called Textbox1 and IFRAME in Default.aspx. There is another page called Default2.aspx which suppose to be shown in IFRAME of Default.aspx page. We add one button called Button1 in Default2.aspx (ChildPage). We wanna get the value of Textbox1 that is placed in Default.aspx (parent page) from Default2.aspx (childpage). So, we have to write the following ocde in Form_load event of default2.aspx. Button1.Attributes.Add ("onclick", "alert(top.document.getElementById('TextBox1').value);"); Yeah. I know that it's not exactly what you want. But the idea is that you have to get the value of controls of the parent page by using Javascript. Then, try to find the way to access the those values from Code-behind. (Using Server-side hidden field is one of the communication between client-side script and server-side script. ) Hope it helps.

            Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

            1 Reply Last reply
            0
            • N Nick cheng liu

              You can do it with javascript. For example: add the following code on the child page function Test() { var parentTextBox = parent.document.getElementById("TextBox1"); //TextBox1 is the ID of TextBox on ParentPage. alert(parentTextBox.value); } I am learning english

              M Offline
              M Offline
              Michael Sync
              wrote on last edited by
              #6

              yeah. I agree with cheng.liu. Javascript is the only way you go.. Rana..

              cheng.liu wrote:

              I am learning english

              Oh. yeah. Me too..

              Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

              1 Reply Last reply
              0
              • N Nick cheng liu

                You can do it with javascript. For example: add the following code on the child page function Test() { var parentTextBox = parent.document.getElementById("TextBox1"); //TextBox1 is the ID of TextBox on ParentPage. alert(parentTextBox.value); } I am learning english

                N Offline
                N Offline
                Nick cheng liu
                wrote on last edited by
                #7

                PS: the Parent page and child page must under the same domain name. // cheng.liu wrote: I am learning english // Oh. yeah. Me too.. //your english is very good. /**-------------------------------------------**/ -- modified at 12:46 Monday 13th August, 2007

                I am learning english.I am still having a few problem, but I getting better. I am very glad if you point my mistake in english. TIA.

                R 1 Reply Last reply
                0
                • N Nick cheng liu

                  PS: the Parent page and child page must under the same domain name. // cheng.liu wrote: I am learning english // Oh. yeah. Me too.. //your english is very good. /**-------------------------------------------**/ -- modified at 12:46 Monday 13th August, 2007

                  I am learning english.I am still having a few problem, but I getting better. I am very glad if you point my mistake in english. TIA.

                  R Offline
                  R Offline
                  rana78
                  wrote on last edited by
                  #8

                  Thanks Everyone. I thought it was not possible, but was not sure so wanted the opinion of others. Thanks a lot again :)

                  Rana78

                  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