For some special reason, we need to display iframe in the form to help user understand what should be input.
I tried to create a custom tool but not working:
Error
Unable to find control with id ‘REQUEST_IFRAME1’ that is associated with the Label ‘REQUEST_IFRAME1_LABEL’.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Unable to find control with id ‘REQUEST_IFRAME1’ that is associated with the Label ‘REQUEST_IFRAME1_LABEL’.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Unable to find control with id ‘REQUEST_IFRAME1’ that is associated with the Label ‘REQUEST_IFRAME1_LABEL’.]
<div class="Field" id="_ROW">
<div class="FieldCaption"><label class="FieldCaptionLabel" for="_IFRAME">IFRAME:</label></div>
<div class="FieldValue"><iframe class="FieldValueInput" id="_IFRAME" src="http://hfy-bi.petrochina-hfy.com/single/?appid=8e14d8a7-155b-422d-b8b2-fb62a2d1fd8f&obj=CtvWC&opt=nointeraction&select=clearall" style="border:none;" scrolling="no" frameborder="0" height="60" width= "600"></iframe>
</div>
Your code is for the definition txt file which cannot be truly executed. It is for the rendering as placeholder for the actual control when the control (field) is being inserted in form designer.
You should have the custom control txt file like this:
<div class=“Field” id="_ROW">
<!-- <%@ Register TagPrefix=“muc” TagName=“MyIframeControl” Src="~/MyIframeControl.ascx" %> -->
<div class=“FieldCaption”><label class=“FieldCaptionLabel” for="_IFRAME">IFRAME:</label></div>
<div class=“FieldValue”><muc:MyIframeControl ID="_MUC1" class=“FieldValueInput” runat=“server” /></div>
</div>
And then prepare a .net usercontrol that has the following in the .ascx file that contains the actual iframe tag:
<%@ Control Language=“C#” AutoEventWireup=“true” CodeFile=“MyIframeControl.ascx.cs” Inherits=“MyIframeControl” %>
<iframe class=“FieldValueInput” id="_IFRAME" runat=“server” src=“http://[your web URL]” style=“border:none;” scrolling=“no” frameborder=“0” height=“60” width= “600”></iframe>
You can even make use of the code behind of the user control (.ascx.cs) file to configure your iframe properties dynamically:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MyIframeControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
//— configure your iframe here if necessary
}
}