0

Iam having two pages Parent.aspx and Child.aspx

Iam using IFrame to show my Child.aspx from parent like this

  <div id="Omit" class="Omit" style="display:none">
      <iframe src="Omission.aspx" width="1000" height="600"></iframe>
    </div>

In my Omission.aspx iam having a label in which i get values from Parent to show in that label

  <div class="Right">

        <p>
            <strong style="color: #000;">Omit</strong>
            <asp:Label ID="lblOne" runat="server" CssClass="lblOne" ClientIDMode="Static" ></asp:Label>

        </p>
    </div>

Here when i assign Text to label iam not getting

   var Text = $(".ddlName option:selected").text(); //Dropdwon of Parent.aspx

i need this value to be assigned to Label which is in Iframe i have tried these ways as

  $(".lblOne").text($(".ddlService option:selected").text())
  $(".lblOne").text(Text);
  $('#<%= lblOne.ClientID %>').html(Text)
  $('#<%= lblOne.ClientID %>').text(Text)

Iam unable to bing Text to that Label.., Can anyone please help me out from this small situation of assigning, Thanks in Advace

þÍńķ
  • 353
  • 1
  • 11
  • 31
  • look at this answer of me: http://stackoverflow.com/questions/15884994/javascript-can-data-be-passed-bi-directionally-through-an-iframe/15928562#15928562 it is little bit more then you need, but probably you need more later. – t.niese Apr 29 '13 at 07:07
  • 2
    Duplicate: http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe – Vimal Stan Apr 29 '13 at 07:10
  • @t.niese But here iam not assigning iframe by Jquery i just want to assign Text to a label which is the other page of iframe – þÍńķ Apr 29 '13 at 07:11
  • @Pink look at the link of VimalStan that's the easiest way. the answer i linked to is for creating a clean interface between parent and iframe. – t.niese Apr 29 '13 at 07:14

1 Answers1

2

Try this:

// 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);
});
palaѕн
  • 72,112
  • 17
  • 116
  • 136