learnerguy
Member
- Joined
- Jul 28, 2013
- Messages
- 20
- Programming Experience
- Beginner
Hi,
I am making a webpage program. when the user clicks preview it calls my function which should get any info in the textboxes and produce a page in real time in the web browser showing the template they chose with the info entered in the program. all it is doing is opening up the page without showing the updated info.
I must be missing something
here is my function
Thanks for taking some time to have a look
-learnerguy
I am making a webpage program. when the user clicks preview it calls my function which should get any info in the textboxes and produce a page in real time in the web browser showing the template they chose with the info entered in the program. all it is doing is opening up the page without showing the updated info.
I must be missing something
here is my function
Function wdmakeit(ByVal wdshowit As Boolean) As String
Try
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
'Reset all the indexes
iCurBonusIndex = 0
iCurFeatureIndex = 0
iCurTestimonialIndex = 0
issSaveToDataset()
Dim sTemplate As String = Application.StartupPath & "\" & gsTempFile
Dim wdonthego As String = Application.StartupPath & "\wdss.html"
'****Open the template file and read in the data into wdfile
Dim myFileIn As IO.StreamReader = IO.File.OpenText(sTemplate)
Dim wdfile As String = myFileIn.ReadToEnd
myFileIn.Close()
'****Read through the wdfile looking for %%'s until no more are found
Dim iStart As Integer = wdfile.IndexOf("%%")
Dim iEnd As Integer
Dim sField As String = ""
Dim drr() As DataRow
Dim dr As DataRow
Dim sBuffer As String = ""
Do While iStart >= 0
iEnd = wdfile.IndexOf("%%", iStart + 2)
sField = wdfile.Substring(iStart, iEnd - iStart).Replace("%", "")
Select Case sField
Case "Feature"
'Use a feature
wdfile = wdfile.Substring(0, iStart) & sBuffer & wdfile.Substring(iEnd + 2)
Case "FeatureEND"
'The final spot for features. Use them up.
Dim iC As Integer
sBuffer = ""
For iC = iCurFeatureIndex To myDs.Tables("Features").Rows.Count
Next
wdfile = wdfile.Substring(0, iStart) & sBuffer & wdfile.Substring(iEnd + 2)
Case "Bonus"
wdfile = wdfile.Substring(0, iStart) & sBuffer & wdfile.Substring(iEnd + 2)
Case "BonusEND"
wdfile = wdfile.Substring(0, iStart) & sBuffer & wdfile.Substring(iEnd + 2)
Case "Testimonial"
wdfile = wdfile.Substring(0, iStart) & sBuffer & wdfile.Substring(iEnd + 2)
Case "TestimonialEND"
'The final spot for testimonials. Use them up.
Dim iC As Integer
sBuffer = ""
For iC = iCurTestimonialIndex To myDs.Tables("Testimonials").Rows.Count
Next
wdfile = wdfile.Substring(0, iStart) & sBuffer & wdfile.Substring(iEnd + 2)
Case "FooterImage"
'background=
'****Once a field has been found. Look in the dataset for the field.
drr = myDs.Tables("Fields").Select("FieldName='" & sField & "'")
If drr.GetUpperBound(0) >= 0 Then
dr = drr(0)
wdfile = wdfile.Replace("%%" & sField & "%%", "Background=" & dr.Item("FieldHTML"))
Else
'****If the field is not found then remove the token
wdfile = wdfile.Replace("%%" & sField & "%%", "")
End If
Case Else
'****Once a field has been found. Look in the dataset for the field.
drr = myDs.Tables("Fields").Select("FieldName='" & sField & "'")
If drr.GetUpperBound(0) >= 0 Then
dr = drr(0)
wdfile = wdfile.Replace("%%" & sField & "%%", dr.Item("FieldHTML"))
Else
'****If the field is not found then remove the token
wdfile = wdfile.Replace("%%" & sField & "%%", "")
End If
End Select
'****Update iStart
iStart = wdfile.IndexOf("%%")
Loop
'****Now update the wdss.html File
If IO.File.Exists(wdonthego) Then
IO.File.Delete(wdonthego)
End If
Dim myFileOut As IO.Stream = IO.File.Open(wdonthego, IO.FileMode.CreateNew)
Dim buffer() As Byte
Dim encoder As New System.Text.ASCIIEncoding
ReDim buffer(wdfile.Length - 1)
encoder.GetBytes(wdfile, 0, wdfile.Length, buffer, 0)
myFileOut.Write(buffer, 0, buffer.Length)
myFileOut.Close()
'****
If wdshowit Then
System.Diagnostics.Process.Start(wdonthego)
'****
End If
Return wdonthego
Exit Function
End Function
Thanks for taking some time to have a look
-learnerguy
Last edited by a moderator: