-
view source
In VB.NET / ASP.NET, I am trying to provide a "view source" button on my
..aspx page which, when pressed, would cause the browser to show the
underlying html/aspx source code for the current page
ASP.NET *dynamically* creates the actual .aspx pages which are delivered to
the client. The delivered pages may differ from the initial static .aspx
pages which are located at (for example) :
c:\inetpub\wwwroot\webapplication1\webform1.aspx
On the client side, the page viewed will exist as a local file located on
the client machine at (for example):
c:\documents and settings\<user name>\local settings\temporary internet
files\webform1.aspx
(w2k, ie6)
On the server side, I don't know where the **dynamically** generated file is
located.
If I knew where the dynamic file was located, potentially I could somehow
use Response.WriteFile() to send the contents across ... ?
-
Re: view source
> In VB.NET / ASP.NET, I am trying to provide a "view source"
> button on my .aspx page which, when pressed, would cause
> the browser to show the underlying html/aspx source code
> for the current page
John: Try this:
http://www.web-source.net/javascript_view_source2.htm
---
Phil Weber
-
Re: view source
Interesting Phil. But I'd like to do it using ASP WebControls ... I want to
get away from editing HTML. Plus, I tried interspersing that code into the
design view of the aspx page and it's tough to figure out how to place it.
What I've been doing is trying a LinkButton with this code behind it:
Dim fsCurrentPage As FileStream
Dim strFullPathCurrentPage As String
strFullPathCurrentPage =
Server.MapPath(Request.ServerVariables("PATH_INFO"))
fsCurrentPage = New FileStream(strFullPathCurrentPage, FileMode.Open)
Response.Write(Server.HtmlEncode(fsCurrentPage.ToString()))
but I got a security error; strangely, the {machinename}\ASP.NET process
does not have rights directly access the aspx files in
c:\inetpub\wwwroot\<app name>
I wonder if there was some way to use a virtual path to grab a file, then
the security error would go away
-
Re: view source
> I'd like to do it using ASP WebControls ... I want to
> get away from editing HTML.
John: Try this:
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim script As String = "<script language=""javascript"">" & _
"function viewSource() { window.location = " & _
"'view-source:' + window.location.href }</script>"
RegisterClientScriptBlock("ViewSource", script)
End Sub
Then set your HyperLink's .NavigateURL property to
"javascript:viewSource()".
---
Phil Weber
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks