Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to fill an iframe with html code
    primarykey
    data
    text
    <p>I am working on a project where HTML code is being generated to display graphs generated by Google's visualization API. So when the page loads it creates an HTML snippet that has the HTML code to display the graphs. What I would like to do is take this raw HTML code and load it into an iframe so it can be displayed on the page. In .NET is there a way to fill an iframe on button click with raw HTML code?</p> <p>VB CODE:<br> public html as String</p> <pre><code> Sub Page_Load(Src As Object, E As EventArgs) Dim htmlHeader As String = "&lt;!DOCTYPE html PUBLIC " &amp; Chr(34) &amp; "-//W3C//DTD XHTML 1.0 Transitional//EN" &amp; Chr(34) &amp; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" &amp; Chr(34) &amp; "&gt;&lt;html xmlns=" &amp; Chr(34) &amp; "http://www.w3.org/1999/xhtml" &amp; Chr(34) &amp; "&gt;&lt;head&gt;&lt;meta http-equiv=" &amp; Chr(34) &amp; "Content-Type" &amp; Chr(34) &amp; " content=" &amp; Chr(34) &amp; "text/html; charset=utf-8" &amp; Chr(34) &amp; " /&gt;&lt;title&gt;Test&lt;/title&gt;" &amp; Chr(60) &amp; "script type = " &amp; Chr(34) &amp; "text/javascript" &amp; Chr(34) &amp; " src = " &amp; Chr(34) &amp; "http://canvg.googlecode.com/svn/trunk/canvg.js" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/script&gt;" &amp; Chr(60) &amp; "script type = " &amp; Chr(34) &amp; "text/javascript" &amp; Chr(34) &amp; " src = " &amp; Chr(34) &amp; "http://canvg.googlecode.com/svn/trunk/rgbcolor.js" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/script&gt;&lt;/head&gt;&lt;body&gt;" Dim htmlFooter As String = Chr(60) &amp; "div&gt;" &amp; Chr(60) &amp; "span class=" &amp; Chr(34) &amp; "float-left" &amp; Chr(34) &amp; " id=" &amp; Chr(34) &amp; "chart1_div" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/span&gt;" &amp; Chr(60) &amp; "span class=" &amp; Chr(34) &amp; "float-left" &amp; Chr(34) &amp; " id=" &amp; Chr(34) &amp; "chart2_div" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/span&gt;" &amp; Chr(60) &amp; "span class=" &amp; Chr(34) &amp; "float-left" &amp; Chr(34) &amp; " id=" &amp; Chr(34) &amp; "chart3_div" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/span&gt;" &amp; Chr(60) &amp; "span class=" &amp; Chr(34) &amp; "float-left" &amp; Chr(34) &amp; " id=" &amp; Chr(34) &amp; "chart4_div" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/span&gt;" &amp; Chr(60) &amp; "span class=" &amp; Chr(34) &amp; "float-left" &amp; Chr(34) &amp; " id=" &amp; Chr(34) &amp; "chart5_div" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/span&gt;" &amp; Chr(60) &amp; "div style=" &amp; Chr(34) &amp; "clear:both" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/div&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;" Dim htmlChartheader As String = Chr(60) &amp; "script src=" &amp; Chr(34) &amp; "https://www.google.com/jsapi" &amp; Chr(34) &amp; " type=" &amp; Chr(34) &amp; "text/javascript" &amp; Chr(34) &amp; "&gt;" &amp; Chr(60) &amp; "/script&gt;" &amp; Chr(60) &amp; "script type=" &amp; Chr(34) &amp; "text/javascript" &amp; Chr(34) &amp; "&gt; /*CACHARTS*/ google.load(" &amp; Chr(34) &amp; "visualization" &amp; Chr(34) &amp; ", " &amp; Chr(34) &amp; "1" &amp; Chr(34) &amp; ", {packages:[" &amp; Chr(34) &amp; "corechart" &amp; Chr(34) &amp; "]}); google.setOnLoadCallback(drawChart); function drawChart() { var data; var chart;" Dim htmlChartfooter As String = " window.scroll(0,0); } " &amp; Chr(60) &amp; "/script&gt;" Dim htmlChart1 As String = "" Dim htmlChart2 As String = "" Dim htmlChart3 As String = "" Dim htmlChart4 As String = "" Dim htmlChart5 As String = "" Dim dataPoints As String = "" Dim qCount As Integer = 0 dataPoints += "data.setValue(" &amp; qCount &amp; ",0,'" &amp; "Q1" &amp; "'); " dataPoints += "data.setValue(" &amp; qCount &amp; ",1," &amp; "141000" &amp; "); " qCount += 1 dataPoints += "data.setValue(" &amp; qCount &amp; ",0,'" &amp; "Q2" &amp; "'); " dataPoints += "data.setValue(" &amp; qCount &amp; ",1," &amp; "151000" &amp; "); " qCount += 1 dataPoints += "data.setValue(" &amp; qCount &amp; ",0,'" &amp; "Q3" &amp; "'); " dataPoints += "data.setValue(" &amp; qCount &amp; ",1," &amp; "161000" &amp; "); " qCount += 1 dataPoints += "data.setValue(" &amp; qCount &amp; ",0,'" &amp; "Q4" &amp; "'); " dataPoints += "data.setValue(" &amp; qCount &amp; ",1," &amp; "145000" &amp; ");" htmlChart1 = "document.getElementById('chart1_div').scrollIntoView();chartTitle = 'Regular &amp; REO Average Sold Price'; xColumn = 'Quarter'; yColumn = 'Avg Sold Price'; zColumn = 'Smoothed'; yTitle = 'Price in Thousands'; chart = new google.visualization.LineChart(document.getElementById('chart1_div')); legendType = 'none'; data = new google.visualization.DataTable(); data.addColumn('string', xColumn); data.addColumn('number', yColumn); data.addColumn('number', zColumn); data.addRows(10); " &amp; dataPoints &amp; "chart.draw(data, {title: chartTitle ,vAxis:{title: yTitle} ,width: 500, height: 500 ,hAxis:{slantedText:true, slantedTextAngle:90, textStyle:{fontSize:10}} ,curveType:'function' ,lineWidth:1 ,pointSize:1 ,legend:'none' ,legend: legendType }); " html = htmlHeader &amp; htmlChartheader &amp; htmlChart1 &amp; htmlChartfooter &amp; htmlFooter textbox1.text = html End sub Sub Button1_Click(Byval sender as object,Byval e as EventArgs) filliFrame(html) End Sub Sub filliFrame(htmlcode as String) This is where I would like to write the HTML to the iFrame ?? iframe.write(htmlcode) ?? End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload