Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource file

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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:
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 -
- Show 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

.



Relevant Pages

  • Re: Posting events to the event viewer.
    ... When I compile my project everything works great. ... If I edit any dialog or anything else in my resource file, ... first data line being "1 11 MOVEABLE PURE" To correct my problem I delete ... NewsMaestro download page: ...
    (microsoft.public.vc.mfc)
  • Re: Posting events to the event viewer.
    ... When I compile my project everything works great. ... If I edit any dialog or anything else in my resource file, ... compile the program I will get a goofy error while compiling the resources. ... first data line being "1 11 MOVEABLE PURE" To correct my problem I delete ...
    (microsoft.public.vc.mfc)
  • Posting events to the event viewer.
    ... I've been using a particular method to post program events to the event ... When I compile my project everything works great. ... If I edit any dialog or anything else in my resource file, ... first data line being "1 11 MOVEABLE PURE" To correct my problem I delete ...
    (microsoft.public.vc.mfc)
  • RC compiler issue
    ... I am using RC.exe to compile a resource file. ... Development Company, L.P.\0" ...
    (microsoft.public.dotnet.languages.vc)
  • Re: URGENT: window.open does not render server-side code when aspx file pulled from a resource f
    ... I have an aspx file stored in a resource file. ... How do I get this to render the C# code properly? ... <html xmlns="http://www.w3.org/1999/xhtml"</a>;> ... protected override void OnLoad ...
    (microsoft.public.dotnet.framework.aspnet)