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