0

I would like to set html body to iframe with this scenario :

     <ItemTemplate>
    <div class="thumb" align="center" style="height:150px;width:130px">
    <asp:Panel ID="Panel2" runat="server" Height="150px" Width="130px">
    <table width="40%" align="center">
    <tr>
    <td>
   <iframe style="overflow:hidden;height:140px;width:120px" src="data:text/html;charset=utf-8,escape(<%#Eval("TemplateBody")%>)"></iframe>
    </td>
    </tr>
    </table>
    </asp:Panel>
     <ajaxToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server" 
    TargetControlID="Panel2" 
    PopupControlID="Panel1" 
    DynamicContextKey='<%# Eval("Id") %>'
    DynamicControlID="Panel1"
    DynamicServiceMethod="GetDynamicContent" 
    Position="Right">
    </ajaxToolkit:PopupControlExtender>
    </div>
    <table width="145px" align="left" style="border-color:Black;border-style:solid;border-width:1px;height:50px">
    <tr>
    <td align="center">
    <table>
    <tr>
    <td><asp:CheckBox ID="ChkSelect" runat="server"/></td>
    <td>&nbsp;&nbsp;</td>
    <td><asp:LinkButton ID="LinkButton2" runat="server" CssClass="quicklink" 
    Text='<%# Eval("TemplateName").ToString().Length > 12 ? Eval("TemplateName").ToString().Substring(0,12)+"..." :Eval("TemplateName") %>' CommandName="ViewTemplate" 
    ToolTip ='<%# Eval("TemplateName")%>' CommandArgument='<%# Eval("Id") %>'></asp:LinkButton>
    <br/>
    <asp:Label ID="Label2" runat="server" CssClass="normaltext" 
    Text='<%# DataBinder.Eval(Container.DataItem, "CreatedDate", "{0:dd/MM/yyyy}") %>' 
    ToolTip='<%# Bind("CreatedDate","{0:F}") %>'></asp:Label></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <asp:Label Visible="false" runat="server" ID="lblNoRecord" Text="No Record Found." ForeColor="Red"></asp:Label>
    </ItemTemplate>

i just want to show html preview with fixed height and with. here this tag is in data list control. but html view not rendered.

Is this correct way to assign html content to iframe src attribute ????

Update

here is data comes from data base :

<p>
     </p>
<p>
    <title></title>
</p>
<table cellpadding='0' cellspacing='0' style='width: 100%;' width='100%'>
    <tbody>
        <tr>
            <td style='vertical-align: top; text-align: center; padding-top: 20px; padding-bottom: 20px;'>
                <table cellpadding='0' cellspacing='0' style='width: 700px;'>
                    <tbody>
                        <tr>
                            <td style='height: 30px; vertical-align: middle; text-align: left; border-top-color: #eeeeee; border-top-width: 3px; border-top-style: solid; background-color: #ffffff;'>
                                <table cellpadding='0' cellspacing='0' style='width: 100%; background-color: #ffffff;'>
                                    <tbody>
                                        <tr>
                                            <td style='width: 60%; vertical-align: middle; text-align: left; padding-left: 10px; padding-top: 10px; padding-bottom: 10px; background-color: #ffffff;'>
                                                <div>
                                                    <span style='vertical-align: middle;'><img alt='' src='http://www.Newsletterservices.in/Templates/SPF_005/images/logo.gif' style='vertical-align: middle;' /></span><span style='vertical-align: middle; font-family: 'trebuchet ms', verdana, 'ms sans-serif'; font-size: 20px; color: #000000; margin-left: 5px;'>##UserOrganisation##</span></div>
                                            </td>
                                            <td style='width: 40%; vertical-align: middle; text-align: right; padding-right: 10px; background-color: #ffffff;'>
                                                <div style='font-size: 16px; color: #000000; font-family: 'trebuchet ms', verdana, 'ms sans serif';'>
                                                    Call Now: ##UserPhone##</div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td style='vertical-align: top; text-align: left; border-color: #e7e7e7 #d5d5d5 #cbcbcb #e7e7e7; border-width: 1px; border-style: solid; background-color: #f6f6f6;'>
                                <table cellpadding='0' cellspacing='0' style='width: 100%;'>
                                    <tbody>
                                        <tr>
                                            <td style='width: 40%; text-align: left; vertical-align: middle; padding: 20px;'>
                                                <div style='font-family: 'trebuchet ms', verdana, 'ms sans-serif'; font-size: 30px; font-weight: bold; color: #323334; line-height: 30px; white-space: normal;'>
                                                    RISK-FREE</div>
                                                <div style='font-family: 'trebuchet ms', verdana, 'ms sans-serif'; font-size: 20px; font-weight: bold; color: #000000; line-height: 20px; white-space: normal;'>
                                                    TRADING OPTIONS</div>
                                                <div style='margin-top: 8px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #757575; line-height: 13px; white-space: normal;'>
                                                    Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here.</div>
                                                <div style='margin-top: 8px;'>
                                                    <span style='vertical-align: middle; white-space: normal;'><a href='#' target='_blank'><img alt='' src='http://www.Newsletterservices.in/Templates/SPF_005/images/btn_start_now.gif' style='vertical-align: middle; border: 0px;' /></a></span></div>
                                            </td>
                                            <td style='width: 60%; text-align: center; vertical-align: bottom; padding-top: 10px; padding-right: 10px; padding-left: 10px;'>
                                                <div>
                                                    <img alt='' src='http://www.Newsletterservices.in/Templates/SPF_005/images/head_img.gif' style='vertical-align: middle;' /></div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td style='vertical-align: middle; text-align: right; padding-top: 10px; padding-bottom: 10px; background-color: #ffffff;'>
                                <table cellpadding='0' cellspacing='0' style='width: 100%;'>
                                    <tbody>
                                        <tr>
                                            <td style='width: 25%; vertical-align: top; text-align: left; padding: 8px; border-bottom-color: #cbcbcb; border-bottom-width: 1px; border-bottom-style: solid; border-top-color: #e7e7e7; border-top-width: 1px; border-top-style: solid; border-left-color: #e7e7e7; border-left-width: 1px; border-left-style: solid; background-color: #17c1fc;'>
                                                <div style='font-family: 'trebuchet ms', verdana, 'ms sans-serif'; font-size: 18px; font-weight: bold; color: #ffffff; line-height: 18px; white-space: normal;'>
                                                    Hghlight Note:</div>
                                            </td>
                                            <td style='width: 75%; vertical-align: top; text-align: left; padding: 8px; border-bottom-color: #cbcbcb; border-bottom-width: 1px; border-bottom-style: solid; border-right-color: #d5d5d5; border-right-width: 1px; border-right-style: solid; border-top-color: #e7e7e7; border-top-width: 1px; border-top-style: solid; background-color: #f7f7f7;'>
                                                <div style='font-family: verdana, 'ms sans-serif'; font-size: 14px; color: #000000; line-height: 14px; white-space: normal;'>
                                                    Insert here highlight note.</div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td style='vertical-align: top; text-align: left; padding-top: 10px; padding-bottom: 10px; background-color: #ffffff;'>
                                <table cellpadding='0' cellspacing='0' style='width: 100%;'>
                                    <tbody>
                                        <tr>
                                            <td style='vertical-align: top; text-align: left; padding-bottom: 10px;'>
                                                <table cellpadding='0' cellspacing='0' style='width: 100%;'>
                                                    <tbody>
                                                        <tr>
                                                            <td style='width: 65%; vertical-align: top; text-align: left; padding-right: 5px;'>
                                                                <div style='font-family: 'trebuchet ms', verdana, 'ms sans-serif'; font-size: 14px; font-weight: bold; color: #2b2b2b; line-height: 14px; white-space: normal;'>
                                                                    Dear ##FirstName## ##LastName##,</div>
                                                                <div style='margin-top: 8px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #2b2b2b; line-height: 13px; white-space: normal;'>
                                                                    Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here.</div>
                                                                <div style='margin-top: 8px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #2b2b2b; line-height: 13px; white-space: normal;'>
                                                                    Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here.</div>
                                                                <div style='margin-top: 8px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #2b2b2b; line-height: 13px; white-space: normal;'>
                                                                    Thank You,</div>
                                                                <div style='font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #2b2b2b; line-height: 13px; white-space: normal;'>
                                                                    Team ##UserOrganisation##</div>
                                                            </td>
                                                            <td style='width: 35%; vertical-align: top; text-align: left; padding-left: 5px; padding-right: 5px;'>
                                                                <div style='white-space: normal;'>
                                                                    <table cellpadding='0' cellspacing='0' style='width: 100%;'>
                                                                        <tbody>
                                                                            <tr>
                                                                                <td style='text-align: left; vertical-align: top; padding: 8px; background-color: #17c1fc;'>
                                                                                    <div style='font-family: 'trebuchet ms', verdana, 'ms sans-serif'; font-size: 16px; color: #ffffff; font-weight: bold; line-height: 16px; white-space: normal;'>
                                                                                        Other Services</div>
                                                                                    <div style='margin-top: 8px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #ffffff; line-height: 13px; font-weight: bold; white-space: normal;'>
                                                                                        Heading-1</div>
                                                                                    <div style='margin-top: 4px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #ffffff; line-height: 13px; white-space: normal;'>
                                                                                        Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here.</div>
                                                                                    <div style='text-align: right; margin-top: 8px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #ffffff; line-height: 13px; white-space: normal;'>
                                                                                        <a href='#' style='font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #ffffff; line-height: 13px; white-space: normal;'>Read More >></a></div>
                                                                                    <div style='margin-top: 8px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #ffffff; line-height: 13px; font-weight: bold; white-space: normal;'>
                                                                                        Heading-1</div>
                                                                                    <div style='margin-top: 4px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #ffffff; line-height: 13px; white-space: normal;'>
                                                                                        Insert some text here. Insert some text here. Insert some text here. Insert some text here. Insert some text here.</div>
                                                                                    <div style='text-align: right; margin-top: 8px; font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #ffffff; line-height: 13px; white-space: normal;'>
                                                                                        <a href='#' style='font-family: verdana, 'ms sans-serif'; font-size: 11px; color: #ffffff; line-height: 13px; white-space: normal;'>Read More >></a></div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                                <td style='vertical-align: middle; text-align: center; height: 10px;'>
                                                                                    <img alt='' src='http://www.Newsletterservices.in/Templates/SPF_005/images/spacer.gif' /></td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td style='vertical-align: top; text-align: left; border-top-color: #eeeeee; border-top-width: 3px; border-top-style: solid; padding: 10px; background-color: #ffffff;'>
                                <div style='text-align: left; font-size: 11px; color: #323334; font-family: verdana, 'ms sans serif'; margin-bottom: 3px; margin-top: 3px;'>
                                    <span><b>Address: </b>##UserAddress1##, ##UserAddress2##, ##UserCity##-##UserPostalCode##</span></div>
                                <div style='text-align: left; font-size: 11px; color: #323334; font-family: verdana, 'ms sans serif'; margin-bottom: 3px;'>
                                    <span><b>Phone: </b>##UserPhone## | <b>Fax: </b>##UserFax##</span></div>
                                <div style='text-align: left; font-size: 11px; color: #323334; font-family: verdana, 'ms sans serif'; margin-bottom: 3px;'>
                                    <span><b>Email: </b><a href='mailto:##UserEmailAddress##' style='text-align: left; font-size: 11px; color: #323334; font-family: verdana, 'ms sans serif';' target='_blank'>##UserEmailAddress##</a> | <b>Visit us at: </b><a href='#' style='text-align: left; font-size: 11px; color: #323334; font-family: verdana, 'ms sans serif';' target='_blank'>http://www.yourdomain.com</a></span></div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
<p>
     </p>

please help me...

1 Answer 1

1

You need to make sure the output of <%#Eval("TemplateBody")%> is html encoded. You also need to be aware that some browsers don't support Data URIs.

You can check a similar question here

Sign up to request clarification or add additional context in comments.

1 Comment

ya that's right with using srcdoc attribute solve my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.