Actually, just discovered a way to do it. Page level, do this:
' Make it so that any external link on the page gets the external
link confirm
' Javascript code added to it.
Dim sOutput As String
Dim nNextOccur As Integer = 0
Dim nFoundAt, nEndElement As Integer
Dim tempWriter = New StringWriter
Dim sURL As String
' Render to a temporary location
MyBase.Render(New HtmlTextWriter(tempWriter))
sOutput = tempWriter.ToString()
Dim sOutputLower As String = sOutput.ToLower ' Some anchors are
upper case - convert to catch all
Try
nFoundAt = sOutputLower.IndexOf("<a ", nNextOccur) ' Find a
tag
Do While nFoundAt <> -1
' Find the end of the anchor
nEndElement = sOutputLower.IndexOf(">", nFoundAt + 1)
sURL = sOutputLower.Substring(nFoundAt, nEndElement -
nFoundAt) ' Get the whole URL
' Add text to both strings to if there is no faa.gov in
the external URL
If sURL.IndexOf("http://") <> -1 And sURL.IndexOf("{Your
Domain here}") = -1 Then
sOutput = sOutput.Insert(nFoundAt + 3,
"onclick=""return confirm('You are leaving the {Whatever} web. The next site
you visit may have a different Privacy Policy. You may want to view the
Privacy Policy at the next site. Click OK to continue.')"" ")
sOutputLower = sOutputLower.Insert(nFoundAt + 3,
"onclick=""return confirm('You are leaving the {Whatever} web. The next site
you visit may have a different Privacy Policy. You may want to view the
Privacy Policy at the next site. Click OK to continue.')"" ")
End If
' Skip over the current anchor and look for the next one
nNextOccur = nEndElement + 1
nFoundAt = sOutputLower.IndexOf("<a ", nNextOccur)
Loop
Catch ex As Exception
' TODO: Put some exception code handling in here
End Try
' Write the final page output
writer.Write(sOutput)
See ya!
Rob
"Rob Heckart" <rh******@nospam.cssiinc.com> wrote in message
news:uV**************@TK2MSFTNGP09.phx.gbl...
Hi,
I'm using the Portal ASP.NET starter kit for a project. It uses one aspx
page, DesktopDefault.aspx to render content by loading different user
controls depending on what's clicked. One of my mandates is to have any
hyperlink on the page that points to a URL outside of our site pull up an
alert message. I have the javascript code, but what I want to know is, can
I see the entire HTML for the page prior to it being sent to the browser?
Once I see that, can I run through it in code and add the code to the URL and
then send the modified HTML to the browser? There's not too much written
about the Render methods and events page level.
Thanks!
Rob