none
How to fetch data from iframe (aspx page)? RRS feed

  • 问题

  • 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
    2009年10月28日 22:38

全部回复


  • parent.document.forms[0].all. crm ntext field .DataValue = The value of 'ClientNameTextBox';
    Batistuta Cai-刀客 | 蔡敏生 | MS CRM MVP | Blog:http://caims.cnblogs.com
    2009年10月29日 2:56
    版主
  • 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.
    2009年10月29日 18:25
  • 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
    • 已建议为答案 Jeff.Han 2009年10月31日 2:21
    2009年10月30日 13:06
    版主
  • 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.

    2009年10月31日 13:58
  • document.frames['IFRAME_yourIFRAME'].document.getElementById('ClientNameTextBox')
    一段一段试
    从document.frames['IFRAME_yourIFRAME']然后向后延申,先确定是哪里的问题
    2009年11月1日 11:32