访问i框架页面中的父页面控件 [英] access parent page controls in i frame page

查看:61
本文介绍了访问i框架页面中的父页面控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面名称为 test.aspx ,它包含一个文本框:

I have a page name as test.aspx, and it contains a textbox:

<asp:TextBox ID="txtCategory" runat="server"></asp:TextBox>



然后我使用iframe页面名称 iframe.aspx



现在我想在iframe页面使用父页面文本框,



我尝试了这个但是它不起作用:


and then I use a iframe page name as iframe.aspx.

Now I want to use parent page text box at iframe page,

I tried this but it not work:

var movedElement = window.parent.document.getElementById(
"<%= txtCategory.ClientID %>");





并给出错误,txtcategory没有存在于当前的大量文章中,



我也尝试使用Hidden字段,但它也无效。

喜欢



and give error that txtcategory not exist in current contaxt,

I also try with Hidden field, but it also not work.
like

var movedElement = window.parent.document.getElementById('HiddenField1');



那么,我该怎么办


So, what can I do

推荐答案

如果你有textbo x在主页面上这将有效。

If you have the textbox on masterpage this will work.
var txtValue = window.parent.form1.txtCategory.value;



但是,如果你在ContentPlaceHolder中有TextBox,有两种方法:

)在完成任务的父页面中编写一个函数,并从iframe中的页面调用函数:


But, if you have TextBox inside ContentPlaceHolder, there are two ways:
1) Write a function in parent page that does your task and call the function from page inside iframe as:

parent.yourParentPageFunction();



2)直接从iframe访问父页面控件并在iframe中的页面上编写函数以访问TextBox:


2) Access parent page control from iframe directly and write the function on the page inside iframe to access the TextBox as:

alert(parent.document.getElementById("ContentPlaceHolder1_TextBox1").value);

here ContentPlaceHolder1_TextBox1是您必须在页面源中找到的父页面上生成的TextBox的ID。

here "ContentPlaceHolder1_TextBox1 " is the ID of the TextBox generated on parent page that you will have to find inside your page source.


HI,



父页面控件将无法在客户端页面中呈现。但是您可以在任何页面中获取控件的值。



您需要将会话或查询字符串值中的值传递给子页面。



谢谢


The parent page control will not be able to render in the client page. But you can able to get the value of the control in any of the pages.

You need to pass the value in a session or in querystring value to the child page.

Thanks




你可以做一件事。将您的父页面的TextBox元素保存在jquery文档就绪函数中的变量中,如下所示:

Hi,
You can do one thing. Save your parent page''s TextBox element in a variable in jquery document ready function like this:
var textBoxElement;


这篇关于访问i框架页面中的父页面控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆