VB.NET > SQL > HTML Tables, how to work with functions - html

On this form, the user performs an inventory search. I have the results of that search displayed in an HTML table.
If rsMPCS.HasRows = False Then
MessageBox.Show("No Item Found")
Else
varHTMLBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf & "<html>" & vbCrLf & "<head>" & vbCrLf & " <title></title>" & vbCrLf
varHTMLBody = varHTMLBody & " <meta http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">" & vbCrLf & "</head>" & vbCrLf
varHTMLBody = varHTMLBody & "<body bgcolor=""#FFFFFF"">" & vbCrLf
varHTMLBody = varHTMLBody & "<table border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-collapse: collapse"" bordercolor=""#000000"" width=""100%"" id=""AutoNumber1" & vbCrLf
varHTMLBody = varHTMLBody & "<tr>" & vbCrLf
varHTMLBody = varHTMLBody & "</tr>" & vbCrLf
varHTMLBody = varHTMLBody & "<tr>" & vbCrLf
varHTMLBody = varHTMLBody & "<tr>" & vbCrLf
varHTMLBody = varHTMLBody & "<table border=0 width=""100%"" height=""200"" cellspacing=""0"" cellpadding=""0"">" & vbCrLf
varHTMLBody = varHTMLBody & "<table width=""100%"" border=1 cellspacing=0 cellspadding=0>" & vbCrLf
varHTMLBody = varHTMLBody & "<td bgcolor=""#000000""><b><font size=4 color=""#FFFFFF"">Part Number: </b></td>" & vbCrLf
varHTMLBody = varHTMLBody & "<td bgcolor=""#000000""><b><font size=4 color=""#FFFFFF"">Description: </b></td>" & vbCrLf
varHTMLBody = varHTMLBody & "<td bgcolor=""#000000""><b><font size=4 color=""#FFFFFF"">Quantity: </b></td>" & vbCrLf
varHTMLBody = varHTMLBody & "<td bgcolor=""#000000""><b><font size=4 color=""#FFFFFF"">Minimum: </b></td>" & vbCrLf
varHTMLBody = varHTMLBody & "<td bgcolor=""#000000""><b><font size=4 color=""#FFFFFF"">Cart </b></td>" & vbCrLf
varHTMLBody = varHTMLBody & "<tr>" & vbCrLf
varHTMLBody = varHTMLBody & "</tr>" & vbCrLf
While rsMPCS.Read
varHTMLBody = varHTMLBody & "<td><font size=2>" & rsMPCS("MTI_PART_NO") & "</td>" & vbCrLf
varHTMLBody = varHTMLBody & "<td><font size=2>" & rsMPCS("Description") & "</td>" & vbCrLf
varHTMLBody = varHTMLBody & "<td><font size=2>" & rsMPCS("STOCKROOM_QTY") & "</td>" & vbCrLf
varHTMLBody = varHTMLBody & "<td><font size=2>" & rsMPCS("MIN_QTY") & "</td>" & vbCrLf
varHTMLBody = varHTMLBody & "<td><img src=""k12169922.jpg"" width=""100"" height=""100""> " & "</td></tr>" & vbCrLf
End While
In the "cart" column is a picture of a shopping cart so they can click the one next to the item they need the inventory dept to fill (this is all internal dept supplies, not external customers)
I'm not sure 1) how to make the image in the cart column launch a function. And 2) how to carry only the information in that particular row over to use on the cart form that I want clicking that image to launch.

Related

Loop through 2 recordsets to create HTML table in an email

I am using Office 365 and trying to create an HTML email from an Access database. I want to generate a table that iterates through 2 record sets. The first recordset is a query displaying "Issues" and the second recordset is a query displaying countermeasures for the issues with a one-to-many relationship between the two. This is how I want to display the tables:
<TABLE>
<TH>Header from Access Table 1 – issue #1</TH>
<TR>Row from Access Table 1– issue #1</TR>
<TH>Header from Access Table 2 – CM # 1</TH>
<TR>Row from Access Table 2 – CM # 1</TR>
</TABLE>
<TABLE>
<TH>Header from Access Table 1 – issue #2</TH>
<TR>Row from Access Table 1– issue #2</TR>
<TH>Header from Access Table 2 – CM # 2</TH>
<TR>Row from Access Table 2 – CM # 2</TR>
</TABLE>
But I am getting:
<TABLE>
<TH>Header from Access Table 1 – issue #1</TH>
<TR>Row from Access Table 1– issue #1</TR>
</TABLE>
<TABLE>
<TH>Header from Access Table 1 – issue #2</TH>
<TR>Row from Access Table 1– issue #2</TR>
</TABLE>
<TABLE>
<TH>Header from Access Table 2 – CM # 2</TH>
<TR>Row from Access Table 2 – CM # 2</TR>
</TABLE>
Can someone point me in the right direction to get my code looping properly?
strSQL2 = "SELECT * FROM qryZoneIssue " & _
" WHERE qryZoneIssue.ZoneMeetingID = " & HoldMeetingID
'*********** display issues & CMs
Set rs2 = CurrentDb.OpenRecordset(strSQL2, dbOpenDynaset)
rs2.MoveFirst
Do While Not rs2.EOF
strBody2 = strBody2 & "<TABLE Border=""1"", Cellspacing=""0""><TR>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">No. </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">KPI </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">Ranking </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">RPS Started </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">Issue Details </p></Font></TH>" & _
"</TR>"
' add the data to the table
strBody2 = strBody2 & "<TR>" & _
"<TD align=center width=""10%"">" & rs2.Fields![ZoneIssueNo].Value & "</TD>" & _
"<TD align=center width=""15%"">" & rs2.Fields![ZoneKPI].Value & "</TD>" & _
"<TD align=center width=""10%"">" & rs2.Fields![ZoneRankID].Value & "</TD>" & _
"<TD align=center width=""15%"">" & rs2.Fields![RPSStarted].Value & "</TD>" & _
"<TD align=left width=""50%"">" & rs2.Fields![ZoneIssue].Value & "</TD>" & _
"</TR>"
strSQL3 = "SELECT * FROM qryZonePermCM " & _
" WHERE qryZonePermCM.ZoneMeetingID = " & HoldMeetingID & "AND ZoneIssueID = " & rs2.Fields![ZoneIssueID].Value
strBody2 = strBody2 & "</table>"
rs2.MoveNext
Loop
Set rs3 = CurrentDb.OpenRecordset(strSQL3, dbOpenDynaset)
rs3.MoveFirst
Do While Not rs3.EOF
strBody2 = strBody2 & "<TABLE Border=""1"", Cellspacing=""0""><TR>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">CM Details </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">Responsible </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">Target Date </p></Font></TH>" & _
' add the data to the table
strBody2 = strBody2 & "<TR>" & _
"<TD align=left width=""40%"">" & rs3.Fields![CMDetails].Value & "</TD>" & _
"<TD align=center width=""15%"">" & rs3.Fields![Responsible].Value & "</TD>" & _
"<TD align=center width=""10%"">" & rs3.Fields![TargetDate].Value & "</TD>" & _
"</TR>"
strBody2 = strBody2 & "</table>"
rs3.MoveNext
Loop
rs3.Close
Need to loop second recordset inside loop of first recordset. Also an error in SQL syntax -- need a space in front of AND: " AND ZoneIssueID = ". Missing a </TR> tag.
Don't start a table for second recordset data.
Consider:
strSQL2 = "SELECT * FROM qryZoneIssue WHERE ZoneMeetingID = " & HoldMeetingID
'*********** display issues & CMs
Set rs2 = CurrentDb.OpenRecordset(strSQL2, dbOpenDynaset)
rs2.MoveFirst
Do While Not rs2.EOF
strBody2 = strBody2 & "<TABLE Border=""1"", Cellspacing=""0""><TR>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">No. </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">KPI </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">Ranking </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">RPS Started </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">Issue Details </p></Font></TH>" & _
"</TR>"
' add the data to the table
strBody2 = strBody2 & "<TR>" & _
"<TD align=center width=""10%"">" & rs2.Fields![ZoneIssueNo].Value & "</TD>" & _
"<TD align=center width=""15%"">" & rs2.Fields![ZoneKPI].Value & "</TD>" & _
"<TD align=center width=""10%"">" & rs2.Fields![ZoneRankID].Value & "</TD>" & _
"<TD align=center width=""15%"">" & rs2.Fields![RPSStarted].Value & "</TD>" & _
"<TD align=left width=""50%"">" & rs2.Fields![ZoneIssue].Value & "</TD>" & _
"</TR>"
strSQL3 = "SELECT * FROM qryZonePermCM WHERE ZoneMeetingID = " & HoldMeetingID & " AND ZoneIssueID = " & rs2!ZoneIssueID
Set rs3 = CurrentDb.OpenRecordset(strSQL3, dbOpenDynaset)
strBody2 = strBody2 & "<TR>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">CM Details </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">Responsible </p></Font></TH>" & _
"<TH Bgcolor=""#2B3856"", Align=""Center""><Font Color=#FFFFFF><b><p style=""font-size:14px"">Target Date </p></Font></TH>" & _
"</TR>"
Do While Not rs3.EOF ' add the data to the table
strBody2 = strBody2 & "<TR>" & _
"<TD align=left width=""40%"">" & rs3.Fields![CMDetails].Value & "</TD>" & _
"<TD align=center width=""15%"">" & rs3.Fields![Responsible].Value & "</TD>" & _
"<TD align=center width=""10%"">" & rs3.Fields![TargetDate].Value & "</TD>" & _
"</TR>"
rs3.MoveNext
Loop
strBody1 = strBody1 & strBody2 & "</table>"
strBody2 = ""
rs3.Close
rs2.MoveNext
Loop
rs2.Close
'set email HTMLbody to strBody1

How to design my html code inside my asp.net code?

How can i put some design in my HTML code inside the vb.net code?
I want to change the font design inside my body tag as the text in my body tag will send in users email address. Your help will greatly appreciated.
here's my code:
mail.Subject = "SYSTEM REQUEST FORM " & txtRequestTitle.Text & " " & Format(Now(), "MM/dd/yyyy").ToString
mail.IsBodyHtml = True
mail.Body = "<html>" & _
"<body>" & _
"Dear " & DropDownApprover.Text & ",<br><br>" & _
"" & "The following request has been created and need your approval" & "<br>" & _
"" & "===============================================" & "<br>" & _
"" & "http://10.190.193.162/ITrequestform/LoginPage.aspx" & "<br>" & _
"" & "===============================================" & "<br>" & _
"" & "Requested By: " & lblName.Text & "<br>" & _
"" & "Need to Approve By: " & DropDownApprover.Text & "<br>" & _
"" & "===============================================" & "<br>" & _
"" & "Request Title: " & txtRequestTitle.Text & "<br>" & _
"" & "Request Category: " & DropDownCateg.Text & "<br>" & _
"" & "Request Item: " & DropDownCateg2.Text & "<br>" & _
"" & "Date Needed: " & txtDateNeeded.Text & "<br>" & _
"" & "===============================================" & "<br>" & _
"" & "For Employee: " & txtRequestEmp.Text & "<br>" & _
"" & "Position: " & txtEmpPost.Text & "<br>" & _
"" & "Description of Request: " & txtDescription.Text & "<br>" & _
"" & "Justification of Request: " & txtJustification.Text & "<br>" & _
"" & "<br>" & _
"Thanks," & "<br>" & _
"HKT Teleservices""<br>" & _
"</body>" & _
"</html>"
Add CSS in project:
In SolutionExplorer --> Right click o project --> Add existing item and select Stylesheet(CSS).
Use CSS in ASPX page:
You need to add refererence for this CSS file in ASPX page
<link href="Stylesheet.css" rel="stylesheet" type="text/css" />
Any style you want to apply to your body text you can write in the code below
And in the Stylesheet.css file, , write this code
body{
font-family:"Helvetica Neue" , "Lucida Grande" , "Segoe UI";
font-size:20px;
}

Structuring HTML so text displays in one paragraph

I'm working on a VBA code in Excel to get input from reports and send emails.
I'm trying to avoid line breaks in my email body.
With olMail
.To = rep
.Subject = title & " - " & EndTitle
'.Recipients.Add rep
.Attachments.Add filePath & "\" & title & " - " & EndTitle & ".pdf"
.htmlBody = "<BODY style=font-size:12pt;font-family:Arial><b><u>Here is an email</u></b></BODY>" & "<BODY style=font-size:12pt;font-family:Arial><b><u>Here is an email</u></b></BODY>" _
& "<br>" & "<b>HK</b>" & "<b>" & amt & "</b>" _
& "<br>" & "Value date" & "<b>" & Trans & "</b>" & "<br>" &
initial
.Display
'.Send
End With
My email looked like this
Here is the email
Here is the email
What I want the email body to look like
Here is the email Here is the email
(on the same line)
Use this instead:
.htmlBody = "<BODY style=font-size:12pt;font-family:Arial><b><u>Here is an emailHere is an email</u></b>" _
& "<br>" & "<b>HK" & amt & "</b>" _
& "<br>" & "Value date" & "<b>" & Trans & "</b>" & "<br>" & initial & "</BODY>"
Or this, depending on which line breaks you want gone:
.htmlBody = "<BODY style=font-size:12pt;font-family:Arial><b><u>Here is an emailHere is an email</u></b>" _
& "<b>HK" & amt & "</b>" _
& "Value date" & "<b>" & Trans & "</b>" & initial & "</BODY>"
See how I encapsulated all the HTML between the opening and closing BODY tags?

How would I insert data from excel into a html table?

I have an excel file which contains data for football statistics and I want to be able to change the excel numbers, and in doing so the website updates its table automatically.
Is there a possible way to do this?
This doesn't completely answer your question, but I thought to include it as a partial answer. I have a generic procedure (method) I use from time to time to convert an Excel Table (aka ListObject) into an HTML table. Perl has a module that does this brilliantly, but I've never found anything similar for VBA, hence my hand-rolled code.
The only caveat is that your data has to be in a table. If it's coming from an RDBMS, then the easiest thing to do is to bring it in via MS Query, which automatically renders the output as a Table/ListObject.
I know you are talking about Web and made no mention of VBA -- just take this for what it's worth. I'm hopeful it has some useful components you can glean.
Function TableToHtml(ByRef Table As ListObject, Title As String) As String
Dim row As ListRow
Dim header, col As range
Dim output As String
output = _
"<html>" & vbCrLf & _
" <head>" & vbCrLf & _
" <title>" & vbCrLf & _
Title & vbCrLf & _
" </title>" & vbCrLf & _
" </head>" & vbCrLf & _
"<body>" & vbCrLf & _
"<font size=""5"">" & Title & "</font><br><br>" & vbCrLf & _
"<table border='1px' cellpadding='5' cellspacing='0' style='border: solid 1px Black; font-size: small;'>"
output = output & "<tr align='center' valign='top'>" & vbCrLf
Set header = Table.HeaderRowRange
For Each col In header.Columns
output = output & " <td align='center' valign='top'>" & col.Value & "</td>" & vbCrLf
Next col
output = output & "</tr>" & vbCrLf
For Each row In Table.ListRows
output = output & "<tr align='left' valign='top'>" & vbCrLf
For Each col In row.range.Columns
output = output & " <td align='center' valign='top'>" & col.Value & "</td>" & vbCrLf
Next col
output = output & "</tr>" & vbCrLf
Next row
Dim o As Object
output = output & "<tr align='left' valign='top'>" & vbCrLf
For Each header In Table.TotalsRowRange
output = output & " <td align='center' valign='top'>" & header.Value & "</td>" & vbCrLf
Next header
output = output & "</tr>" & vbCrLf
output = output & "</table>" & vbCrLf & "</body>" & vbCrLf & "</html>"
TableToHtml = output
End Function
Yes, this is pretty brute-force.

how to fill an iframe with html code

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?
VB CODE:
public html as String
Sub Page_Load(Src As Object, E As EventArgs)
Dim htmlHeader As String = "<!DOCTYPE html PUBLIC " & Chr(34) & "-//W3C//DTD XHTML 1.0 Transitional//EN" & Chr(34) & "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" & Chr(34) & "><html xmlns=" & Chr(34) & "http://www.w3.org/1999/xhtml" & Chr(34) & "><head><meta http-equiv=" & Chr(34) & "Content-Type" & Chr(34) & " content=" & Chr(34) & "text/html; charset=utf-8" & Chr(34) & " /><title>Test</title>" & Chr(60) & "script type = " & Chr(34) & "text/javascript" & Chr(34) & " src = " & Chr(34) & "http://canvg.googlecode.com/svn/trunk/canvg.js" & Chr(34) & ">" & Chr(60) & "/script>" & Chr(60) & "script type = " & Chr(34) & "text/javascript" & Chr(34) & " src = " & Chr(34) & "http://canvg.googlecode.com/svn/trunk/rgbcolor.js" & Chr(34) & ">" & Chr(60) & "/script></head><body>"
Dim htmlFooter As String = Chr(60) & "div>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart1_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart2_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart3_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart4_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart5_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "div style=" & Chr(34) & "clear:both" & Chr(34) & ">" & Chr(60) & "/div></div></body></html>"
Dim htmlChartheader As String = Chr(60) & "script src=" & Chr(34) & "https://www.google.com/jsapi" & Chr(34) & " type=" & Chr(34) & "text/javascript" & Chr(34) & ">" & Chr(60) & "/script>" & Chr(60) & "script type=" & Chr(34) & "text/javascript" & Chr(34) & "> /*CACHARTS*/ google.load(" & Chr(34) & "visualization" & Chr(34) & ", " & Chr(34) & "1" & Chr(34) & ", {packages:[" & Chr(34) & "corechart" & Chr(34) & "]}); google.setOnLoadCallback(drawChart); function drawChart() { var data; var chart;"
Dim htmlChartfooter As String = " window.scroll(0,0); } " & Chr(60) & "/script>"
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(" & qCount & ",0,'" & "Q1" & "'); "
dataPoints += "data.setValue(" & qCount & ",1," & "141000" & "); "
qCount += 1
dataPoints += "data.setValue(" & qCount & ",0,'" & "Q2" & "'); "
dataPoints += "data.setValue(" & qCount & ",1," & "151000" & "); "
qCount += 1
dataPoints += "data.setValue(" & qCount & ",0,'" & "Q3" & "'); "
dataPoints += "data.setValue(" & qCount & ",1," & "161000" & "); "
qCount += 1
dataPoints += "data.setValue(" & qCount & ",0,'" & "Q4" & "'); "
dataPoints += "data.setValue(" & qCount & ",1," & "145000" & ");"
htmlChart1 = "document.getElementById('chart1_div').scrollIntoView();chartTitle = 'Regular & 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); " & dataPoints & "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 & htmlChartheader & htmlChart1 & htmlChartfooter & 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
I was able to accomplish this by storing the html code into a hidden field and using a JavaScript function to push the code to the iFrame.
VB CODE:
Sub Page_Load(Src As Object, E As EventArgs)
Dim html as String = ""
Dim htmlHeader As String = "<!DOCTYPE html PUBLIC " & Chr(34) & "-//W3C//DTD XHTML 1.0 Transitional//EN" & Chr(34) & "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" & Chr(34) & "><html xmlns=" & Chr(34) & "http://www.w3.org/1999/xhtml" & Chr(34) & "><head><meta http-equiv=" & Chr(34) & "Content-Type" & Chr(34) & " content=" & Chr(34) & "text/html; charset=utf-8" & Chr(34) & " /><title>Test</title>" & Chr(60) & "script type = " & Chr(34) & "text/javascript" & Chr(34) & " src = " & Chr(34) & "http://canvg.googlecode.com/svn/trunk/canvg.js" & Chr(34) & ">" & Chr(60) & "/script>" & Chr(60) & "script type = " & Chr(34) & "text/javascript" & Chr(34) & " src = " & Chr(34) & "http://canvg.googlecode.com/svn/trunk/rgbcolor.js" & Chr(34) & ">" & Chr(60) & "/script></head><body>"
Dim htmlFooter As String = Chr(60) & "div>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart1_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart2_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart3_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart4_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "span class=" & Chr(34) & "float-left" & Chr(34) & " id=" & Chr(34) & "chart5_div" & Chr(34) & ">" & Chr(60) & "/span>" & Chr(60) & "div style=" & Chr(34) & "clear:both" & Chr(34) & ">" & Chr(60) & "/div></div></body></html>"
Dim htmlChartheader As String = Chr(60) & "script src=" & Chr(34) & "https://www.google.com/jsapi" & Chr(34) & " type=" & Chr(34) & "text/javascript" & Chr(34) & ">" & Chr(60) & "/script>" & Chr(60) & "script type=" & Chr(34) & "text/javascript" & Chr(34) & "> /*CACHARTS*/ google.load(" & Chr(34) & "visualization" & Chr(34) & ", " & Chr(34) & "1" & Chr(34) & ", {packages:[" & Chr(34) & "corechart" & Chr(34) & "]}); google.setOnLoadCallback(drawChart); function drawChart() { var data; var chart;"
Dim htmlChartfooter As String = " window.scroll(0,0); } " & Chr(60) & "/script>"
Dim htmlChart1 As String = ""
Dim dataPoints As String = ""
Dim qCount As Integer = 0
dataPoints += "data.setValue(" & qCount & ",0,'" & "Q1" & "'); "
dataPoints += "data.setValue(" & qCount & ",1," & "141000" & "); "
qCount += 1
dataPoints += "data.setValue(" & qCount & ",0,'" & "Q2" & "'); "
dataPoints += "data.setValue(" & qCount & ",1," & "151000" & "); "
qCount += 1
dataPoints += "data.setValue(" & qCount & ",0,'" & "Q3" & "'); "
dataPoints += "data.setValue(" & qCount & ",1," & "161000" & "); "
qCount += 1
dataPoints += "data.setValue(" & qCount & ",0,'" & "Q4" & "'); "
dataPoints += "data.setValue(" & qCount & ",1," & "145000" & ");"
htmlChart1 = "document.getElementById('chart1_div').scrollIntoView();chartTitle = 'Regular & 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); " & dataPoints & "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 & htmlChartheader & htmlChart1 & htmlChartfooter & htmlFooter
lblhtmlholder.text = html
End sub
Sub Button1_Click(Byval sender as object,Byval e as EventArgs)
hdnTextbox1.Value = lblhtmlholder.text
filliFrame()
End Sub
Sub filliFrame()
Page.ClientScript.RegisterStartupScript(Me.GetType(), "myKey", "injectHTML();", True)
End Sub
HTML CODE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type = "text/javascript" src = "//canvg.googlecode.com/svn/trunk/canvg.js"></script>
<script type = "text/javascript" src = "//canvg.googlecode.com/svn/trunk/rgbcolor.js"></script>
<script type = "text/javascript">
function injectHTML(){
//step 1: get the DOM object of the iframe.
var iframe = document.getElementById('iFrame1');
var html_string = document.getElementById("hdnTextbox1").value
document.getElementById("hdnTextbox1").value = ""
try{
//step 2: obtain the document associated with the iframe tag
//most of the browser supports .document. Some supports (such as the NetScape series) .contentDocumet, while some (e.g. IE5/6) supports .contentWindow.document
//we try to read whatever that exists.
var iframedoc = iframe.document;
if (iframe.contentDocument)
iframedoc = iframe.contentDocument;
else if (iframe.contentWindow)
iframedoc = iframe.contentWindow.document;
if (iframedoc){
// Put the content in the iframe
iframedoc.open();
iframedoc.writeln(html_string);
iframedoc.close();
} else {
//just in case of browsers that don't support the above 3 properties.
alert('Cannot inject dynamic contents into iframe.');
}
}
catch(err)
{
alert(err.message);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:label id="lblHtmlHolder" runat="server" visible="false" />
<input type="hidden" id="hdnTextbox1" runat="server" />
<input type="hidden" id="hdnChart1" runat="server" />
<asp:Button ID="button1" runat="server" Text="Fill iFrame" OnClick="Button1_Click" />
<iframe id="iFrame1" runat="server" style="width:700px; height:400px;" />
</form>
</body>
</html>