Iam有两页Parent.aspx和Child.aspx
我使用IFrame来显示来自父母的Child.aspx,如此
<div id="Omit" class="Omit" style="display:none">
<iframe src="Omission.aspx" width="1000" height="600"></iframe>
</div>
在我的Omission.aspx中,我有一个标签,其中我从父母那里获得值以显示在该标签中
<div class="Right">
<p>
<strong style="color: #000;">Omit</strong>
<asp:Label ID="lblOne" runat="server" CssClass="lblOne" ClientIDMode="Static" ></asp:Label>
</p>
</div>
这时我指定文字到标签iam没有得到
var Text = $(".ddlName option:selected").text(); //Dropdwon of Parent.aspx
我需要将此值分配给Iframe中的Label 我试过这些方式
$(".lblOne").text($(".ddlService option:selected").text())
$(".lblOne").text(Text);
$('#<%= lblOne.ClientID %>').html(Text)
$('#<%= lblOne.ClientID %>').text(Text)
我无法将文字绑定到该标签.., 任何人都可以帮我解决这个小小的分配情况, 感谢Advace
答案 0 :(得分:2)
试试这个:
// Get the iFrame jQuery Object
var $MyFrame = $("#iframeid");
// You need to wait for the iFrame content to load first
// So, that the click events work properly
$MyFrame.load(function () {
var frameBody = $MyFrame.contents().find('body');
// Find the label
var $label = frameBody.find('.lblOne');
// Set the label text
$label.html(Text);
});