Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- From: "Bob Jones" <goodoldave@xxxxxxxxx>
- Date: 20 Feb 2007 09:38:25 -0800
On Feb 20, 11:59 am, "Patrice" <http://www.chez.com/scribe/> wrote:
This is correct but the problem is that the resource architecture doesn't
care this is ASPX code. From a resource point of view this is just some
text. So ASP.NET doesn't compile and run this...
I don't really see an obvious way to do this with your requirements. You
could perhaps have a server side page that fetch this resource, then use
System.Net.WebClient to call the page and then return the resulting HTML
while deleting the temporary page hoping yiour requirements really needs
these kind of cumbersome architecture...
"Bob Jones" <goodold...@xxxxxxxxx> a écrit dans le message de news:
1171989383.468841.92...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 20, 11:22 am, bruce barker <nos...@xxxxxxxxxx> wrote:
asp.net will not compile an aspx page in a resource, so you approach
will not work. if you just leave it in the dir, asp.net will compile it
before returning the page.
you only trick will be deploying the code if you use a precompiled site.
you will need to compile the site, then add the aspx file to the
compiled site dir (use a custom build step).
-- bruce (sqlwork.com)
Bob Jones wrote:
On Feb 20, 9:27 am, "Patrice" <http://www.chez.com/scribe/> wrote:
It looks like to me the whole content of an ASPX page is stored inside
a
resource ? Is this correct ? A resource just stores some data so the
ASP.NET
engine doesn't have any idea that this is actually something you would
like
to run (I'm surprised even it lets you serve resx files).
I'm not sure what is the overall goal but the first idea that comes to
mind
would be to save this in an ASPX file as usual. Else elaborate on what
you
are trying to do in case someone would have a simpler approach to
suggest...
"Bob Jones" <goodold...@xxxxxxxxx> a écrit dans le message de news:
1171980219.088072.326...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Here is my situation:- Show quoted text -
I have an aspx file stored in a resource file. All of the C# code is
written inline via <script runat="server"> tags. Let's call this page
B. I also have page A that contains some javascript code that calls
window.open. I pass the resource url of page B to Page A's window.open
call. Page B is then loaded and executed but none of the server-side
code is rendered. If I view the source of the page, the code (and page
declaration) are visible.
How do I get this to render the C# code properly?
Sample code:
Assembly.cs
[assembly: WebResourceAttribute("MyTest.MyFile.aspx", "text/html",
PerformSubstitution = true)]
PageA.aspx (C#)
public string ns = "";
protected void Page_Load(object sender, EventArgs e)
{
ns = Page.ClientScript.GetWebResourceUrl(GetType(),
"MyTest.MyFile.aspx");
}
PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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 runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
<!--
function Button1_onclick()
{
window.open(<%=ns%>, "_blank",
"menubar=no,titlebar=no,toolbar=no,status=no");
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="javascript" onclick="return Button1_onclick()" />
</body>
</html>
MyFile.ascx (stored in resource file)
<%@ Page Language="C#" %>
<html>
<head runat="server">
<title>MyTitle</title>
</head>
<body bgcolor="#6699cc">
<form id="form1" runat="server">
</form>
</body>
</html>
<script runat="server" type="text/C#">
protected override void OnLoad(EventArgs e)
{
Response.Write("I am writing to dee page!");
base.OnLoad(e);
}
</script>- Hide quoted text -
Patrice,
You are correct, I am trying to serve up an aspx page that is stored
in a resource file.
What I am trying to accomplish is to allow an aspx page or control to
be displayed in a pop-up window when a user clicks on a hyperlink in a
web page. The page that needs to be displayed could be stored anywhere
on the site and should be easily editable by a novice developer (no
asp.net server controls which require writing the control without a
designer) but the pages should not be accessible to a user by typing
it in the url directly.
I was hoping I could mask this by storing a generic aspx file in a
resource file and pass in say a namespace or something that the
embedded pages c# code would then invoke and render to the page.
Is my methodology wrong? Is there a better or more common approach?
-David- Hide quoted text -
- Show quoted text -
Bruce,
I appreciate the response but what you mentioned does not solve my
problem nor does it suggest anything other than placing a static page
on the web site. I also mentioned that the c# code is inline and, to
the best of my knowledge, the page is not compiled until runtime.
Am I not correct about this?
-David- Hide quoted text -
- Show quoted text -
Is there a way to make ASp.Net render this page as an aspx page
instead of a text file? I was under the impression that since I am
getting a resource and then rendering it in the browser as html
asp.net would parse it all out properly? Maybe the MIME type of text/
html is not correct? If I change it to text/aspx then it prompts me to
download the .axd resource file
Is there perhaps a better way to accomplish what I want to do?
-David
.
- Follow-Ups:
- References:
- URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- From: Bob Jones
- Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- From: Patrice
- Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- From: Bob Jones
- Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- From: bruce barker
- Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- From: Bob Jones
- Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- From: Patrice
- URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- Prev by Date: Re: aspx cannot show
- Next by Date: Re: event handler in VS 2005 designer
- Previous by thread: Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- Next by thread: Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file
- Index(es):
Relevant Pages
|