A
AAaron123
In the aspx:
<%@ MasterType VirtualPath="~/Main.master" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="RightCPH">
<div runat="server" style="overflow: auto;" id="History_Parish">
This text gets replaced</div>
</asp:Content>
The reason for the text "This text gets replaced" is that I copy new text to
InnerHtml
In the code behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Master.CopyToControlInnerHtml("History\Parish.htm", History_Parish)
End Sub
In the master:
Public Sub CopyToControlInnerHtml(ByVal filename As String,
ByVal ctl As HtmlGenericControl)
Dim fileNameIn As String = Session("TopDirectory") & filename
Dim sr As System.IO.StreamReader
Dim strContents As String = ""
If System.IO.File.Exists(fileNameIn) Then
sr = System.IO.File.OpenText(fileNameIn)
strContents += sr.ReadToEnd()
sr.Close()
Dim pos1 As Integer = strContents.IndexOf("<body")
Dim bodyText As String = strContents.Substring(pos1)
Dim pos2 As Integer = bodyText.IndexOf(">") 'Find end of <body ...>
Dim bodyText2 As String = bodyText.Substring(pos2 + 1).
Replace("</body>", "").Replace("</html>", "")
ctl.InnerHtml = bodyText2
End If
End Sub
As you see I copy the text inside the body elements to InnerHtml.
Seems kind of kludgy to me.
Is there a better way?
Thanks in advance
BTW
Do most Asp.Net developers use .HTM or .HTML??
<%@ MasterType VirtualPath="~/Main.master" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="RightCPH">
<div runat="server" style="overflow: auto;" id="History_Parish">
This text gets replaced</div>
</asp:Content>
The reason for the text "This text gets replaced" is that I copy new text to
InnerHtml
In the code behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Master.CopyToControlInnerHtml("History\Parish.htm", History_Parish)
End Sub
In the master:
Public Sub CopyToControlInnerHtml(ByVal filename As String,
ByVal ctl As HtmlGenericControl)
Dim fileNameIn As String = Session("TopDirectory") & filename
Dim sr As System.IO.StreamReader
Dim strContents As String = ""
If System.IO.File.Exists(fileNameIn) Then
sr = System.IO.File.OpenText(fileNameIn)
strContents += sr.ReadToEnd()
sr.Close()
Dim pos1 As Integer = strContents.IndexOf("<body")
Dim bodyText As String = strContents.Substring(pos1)
Dim pos2 As Integer = bodyText.IndexOf(">") 'Find end of <body ...>
Dim bodyText2 As String = bodyText.Substring(pos2 + 1).
Replace("</body>", "").Replace("</html>", "")
ctl.InnerHtml = bodyText2
End If
End Sub
As you see I copy the text inside the body elements to InnerHtml.
Seems kind of kludgy to me.
Is there a better way?
Thanks in advance
BTW
Do most Asp.Net developers use .HTM or .HTML??