Resources for IT Professionals > Dynamics Forums > CRM Chinese > How to fetch data from iframe (aspx page)?
Ask a questionAsk a question
 

Proposed AnswerHow to fetch data from iframe (aspx page)?

  • Wednesday, October 28, 2009 10:38 PM狐狸糊涂 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I have a iFrame, calling a aspx file, in my crm form. In the aspx file, I have an element with asp:TextBox ID='ClientNameTextBox'.

    How can I fetch this textbox value from iframe and pass to another crm ntext field Client Name? 

    Please help me ....
    Thank you,

    DD

All Replies

  • Thursday, October 29, 2009 2:56 AMBatistuta CaiMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    parent.document.forms[0].all. crm ntext field .DataValue = The value of 'ClientNameTextBox';
    Batistuta Cai-刀客 | 蔡敏生 | MS CRM MVP | Blog:http://caims.cnblogs.com
  • Thursday, October 29, 2009 6:25 PM狐狸糊涂 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thank you very much for your reply, Batistuta.

    Maybe I didn't make it clear ... actually, my question has two parts ...
    1. get a value from iFrame (aspx file). <asp:TextBox ID='ClientNameTextBox'> is the field used to hold the value I want
    2. Pass the fetched value to a crm form field (Client Name, type is ntext)

    I would like to put this piece of javascript in OnLoad event. ie...
    When a crm form opened, the aspx file loaded in iFrame, and meanwhile the Client Name is passed from iFrame (aspx file) to a ntext field.

    Any ideas ...

    Thank you,
    DD.
  • Friday, October 30, 2009 1:06 PMdarrenliuMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed AnswerHas Code
    DD,

    另外一个人在英文的论坛上回答了, 看看行不行。我看可以的。

    1. To "enable cross site scripting on the iFrame" is .... to uncheck the security option "Restrict cross-frame scripting ", right?
    That's right.
    2. I put the calling page (aspx file) under \\maxcrm\c$\Program Files\Microsoft Dynamics CRM\CRMWeb\ISV. I think it should be OK.

    still get error messages .... "Object dosen't support this property or method"

    Any helps ....

    Try this:
    var field = document.frames['IFRAME_yourIFrame'].document.getElementById('ClientNameTextBox');
    crmForm.all.crmClientName.DataValue = field.value;

    Darren Liu | 刘嘉鸿 | MS CRM MVP | English Blog: http://msdynamicscrm-e.blogspot.com | Chinese Blog: http://liudarren.spaces.live.com
    • Proposed As Answer by小寧 Saturday, October 31, 2009 2:21 AM
    •  
  • Saturday, October 31, 2009 1:58 PM狐狸糊涂 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I tried the suggestion. It works but gives wrong result.

    The error message changed to ..... "Object required."

    I tested with alter(field), it gave "null". Any idea about this?

    My sinerio is ...
    1. onLoad event, pass a ClientID to IFRAME;
    2. IFRAME display the client information (aspx file search database by ClientID);
    3. onSave event, pass ClientNameTextBox from aspx to crm field crmClientName ;

    I set the text value of ClientNameTextBox to a consitant string "HelloClientName", instead of binding to database ...
    <asp:TextBox ID="ClientNameTextBox" runat="server" Text='HelloClientName' />

    Then I test with ...
    var field = document.frames['IFRAME_yourIFRAME'].document.getElementById('ClientNameTextBox');
    alert(field);

    Still I got alert ... "Null"

    Any ideas ...?

    Thank you,
    DD.

  • Sunday, November 01, 2009 11:32 AM小寧 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    document.frames['IFRAME_yourIFRAME'].document.getElementById('ClientNameTextBox')
    一段一段试
    从document.frames['IFRAME_yourIFRAME']然后向后延申,先确定是哪里的问题