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

Discussion in 'ASP .Net' started by Bob Jones, Feb 20, 2007.

  1. Bob Jones

    Bob Jones Guest

    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>
    Bob Jones, Feb 20, 2007
    #1
    1. Advertising

  2. Bob Jones

    Axel Dahmen Guest

    Hi Bob,

    have you tried opening Page B by entering its URL? It doesn't make any difference for the server whether you open a page using JavaScript or any other way. I guess your page doesn't work at all. Did you use any of the file extensions recognized by ASP.NET for your page?

    HTH,
    Axel Dahmen

    -----------------
    "Bob Jones" <> schrieb im Newsbeitrag news:...
    > 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>
    >
    Axel Dahmen, Feb 20, 2007
    #2
    1. Advertising

  3. Bob Jones

    Bob Jones Guest

    On Feb 20, 9:13 am, "Axel Dahmen" <> wrote:
    > Hi Bob,
    >
    > have you tried opening Page B by entering its URL? It doesn't make any difference for the server whether you open a page using JavaScript or any other way. I guess your page doesn't work at all. Did you use any of the file extensions recognized by ASP.NET for your page?
    >
    > HTH,
    > Axel Dahmen
    >
    > -----------------
    > "Bob Jones" <> schrieb im Newsbeitragnews:...
    >
    >
    >
    > > 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 -



    Axel,

    Calling the page directly produces the same output. I am not sure I am
    understanding how I would go about addid the .aspx extention to the
    resource url as it looks like this:
    http://localhost:1169/WebResource.a...Dt2iDFTwJmMyOOy7eXR2j5Y1&t=633075600008593750

    I do, however, think you may be on to something. As a side note, if
    you view the source of the page you will see exactly was is specified
    (verbatim) under the MyFile.ascx (stored in resource file) section I
    posted eairler.

    -David
    Bob Jones, Feb 20, 2007
    #3
  4. Bob Jones

    Patrice Guest

    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" <> a écrit dans le message de news:
    ...
    > 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>
    >
    Patrice, Feb 20, 2007
    #4
  5. Bob Jones

    Bob Jones Guest

    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" <> a écrit dans le message de news:
    > ...
    >
    >
    >
    > > 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
    Bob Jones, Feb 20, 2007
    #5
  6. Bob Jones

    bruce barker Guest

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

    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" <> a écrit dans le message de news:
    >> ...
    >>
    >>
    >>
    >>> 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
    >
    bruce barker, Feb 20, 2007
    #6
  7. Bob Jones

    Bob Jones Guest

    On Feb 20, 11:22 am, bruce barker <> 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" <> a écrit dans le message de news:
    > >> ...

    >
    > >>> 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
    Bob Jones, Feb 20, 2007
    #7
  8. Bob Jones

    Patrice Guest

    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" <> a écrit dans le message de news:
    ...
    On Feb 20, 11:22 am, bruce barker <> 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" <> a écrit dans le message de news:
    > >> ...

    >
    > >>> 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
    Patrice, Feb 20, 2007
    #8
  9. Bob Jones

    Bob Jones Guest

    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" <> a écrit dans le message de news:
    > ...
    > On Feb 20, 11:22 am, bruce barker <> 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" <> a écrit dans le message de news:
    > > >> ...

    >
    > > >>> 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- 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
    Bob Jones, Feb 20, 2007
    #9
  10. Bob Jones

    Axel Dahmen Guest

    Hi Bob,

    can you please be a bit more precise on what you're planning to do? I don't get the picture from what you've wrote.

    Here's my comments on what I understood from your text:

    > 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.

    = JavaScript, no ASP.NET magic.


    > The page that needs to be displayed could be stored anywhere

    on the site

    = ... like any .aspx page does ...


    > and should be easily editable by a novice developer


    = ... again like any .aspx page does. ASP.NET is no more difficult to author than HTML.


    > (no asp.net server controls which require writing the control without

    a designer)

    = I guess, you mean "with a designer". In fact a designer is not required for ASP.NET. Designer feature is just a nifty service provided by Visual Studio.


    > but the pages should not be accessible to a user by typing it in the url directly.


    = ... like any .aspx page does ...


    > 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?


    = Well, it depends. If you want others to dynamically add code to pages you've written, you might want to:

    * Create a public interface allowing other users to implement it
    in their classes.

    * give public read/write access to the App_Code directory so
    others may add new classes to that directory

    * Use the interface definition mentioned above into your aspx file
    and use Reflection to create the newly created classes from the
    App_Code directory.

    * Add a URL parameter to the page to be able to provide the class
    name to Reflection.


    HTH,
    Axel
    Axel Dahmen, Feb 20, 2007
    #10
  11. Bob Jones

    Axel Dahmen Guest

    >> but the pages should not be accessible to a user by typing it in the url directly.
    >
    >= ... like any .aspx page does ...



    Oops... Didn't read the "not".

    Page content MUST be accessible by a URL. In fact, there's no way to call ANY content in any other way. Even your .axd call is a valid URL. Anyone can call it with no problem. The file extension doesn't make any difference.
    Except for the server, switching on ASP.NET processing only for certain file extensions. But this doesn't affect the client in any way.

    HTH,
    Axel
    Axel Dahmen, Feb 20, 2007
    #11
  12. Bob Jones

    Patrice Guest

    IMO no. This information is for the client. Im' not sure how you could tell
    the server that it has to do something on the resource before sending back
    the result.

    Keep in mind that the webresource stuff was done to serve "raw" content.

    "Bob Jones" <> a écrit dans le message de news:
    ...
    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" <> a écrit dans le message de news:
    > ...
    > On Feb 20, 11:22 am, bruce barker <> 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" <> a écrit dans le message de news:
    > > >> ...

    >
    > > >>> 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- 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
    Patrice, Feb 21, 2007
    #12
  13. Bob Jones

    Bob Jones Guest

    On Feb 21, 3:42 am, "Patrice" <http://www.chez.com/scribe/> wrote:
    > IMO no. This information is for the client. Im' not sure how you could tell
    > the server that it has to do something on the resource before sending back
    > the result.
    >
    > Keep in mind that the webresource stuff was done to serve "raw" content.
    >
    > "Bob Jones" <> a écrit dans le message de news:
    > ...
    > 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" <> a écrit dans le message de news:
    > > ...
    > > On Feb 20, 11:22 am, bruce barker <> 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" <> a écrit dans le message de news:
    > > > >> ...

    >
    > > > >>> 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- 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- Hide quoted text -
    >
    > - Show quoted text -


    Patrice,

    Thanks for the help. I guess I need to find a better way of doing
    this. I have been expereimenting with creating a new Page object from
    scratch. What does everyone think of this? Mabye I should try
    something else? Only problem I found with this way is that I do not
    have request or response objects to do a server.transfer from. I can
    probably solve my problem if I could just render the contents of some
    controls behind the scenes (against a valid page model) and then send
    the render HTML content to the page directly.

    Any thoughts?

    David
    Bob Jones, Feb 21, 2007
    #13
  14. Bob Jones

    Patrice Guest

    Random thoughts as I'm not sure about the details of your requirements...

    First of all I would not let place them pages wherever they want on the
    server (to get something better manageable).

    You could for example :
    - create them a working directory (possibly as a GUID)
    - the real pages could perhaps be stored there using also a GUID for their
    name so that direct access is made difficult if not impossible, pages are
    uplaoded using your own interface
    - a rewriting URL module could expose those pages under a friendly name of
    their choice (i.e. they don't know their real location). This module could
    prevent direct access (if I remember you wanted them not being able to using
    a link to their pages unless in a particular context, not sure how you
    would know you are in an appropriate context ?).

    A still higher level view could perhaps help as you seem to have quite
    unusual requirements. Also I believe I saw once a sample that uses VS.NET to
    let third party customize a web application (if this is what you are doing)
    exposing an object model allowing to hook up into events.

    It could be also something like Gadgets or WebParts ?

    Good luck.


    "Bob Jones" <> a écrit dans le message de news:
    ...
    On Feb 21, 3:42 am, "Patrice" <http://www.chez.com/scribe/> wrote:
    > IMO no. This information is for the client. Im' not sure how you could
    > tell
    > the server that it has to do something on the resource before sending back
    > the result.
    >
    > Keep in mind that the webresource stuff was done to serve "raw" content.
    >
    > "Bob Jones" <> a écrit dans le message de news:
    > ...
    > 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" <> a écrit dans le message de news:
    > > ...
    > > On Feb 20, 11:22 am, bruce barker <> 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" <> a écrit dans le message de news:
    > > > >> ...

    >
    > > > >>> 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- 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- Hide quoted text -
    >
    > - Show quoted text -


    Patrice,

    Thanks for the help. I guess I need to find a better way of doing
    this. I have been expereimenting with creating a new Page object from
    scratch. What does everyone think of this? Mabye I should try
    something else? Only problem I found with this way is that I do not
    have request or response objects to do a server.transfer from. I can
    probably solve my problem if I could just render the contents of some
    controls behind the scenes (against a valid page model) and then send
    the render HTML content to the page directly.

    Any thoughts?

    David
    Patrice, Feb 21, 2007
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2lsZWVzaA==?=
    Replies:
    2
    Views:
    443
    Joe Fallon
    Apr 8, 2004
  2. =?Utf-8?B?QXJuZQ==?=

    Server side code in-side aspx

    =?Utf-8?B?QXJuZQ==?=, Apr 18, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    568
    Brock Allen
    Apr 18, 2005
  3. Charlie@CBFC
    Replies:
    1
    Views:
    2,826
    Arlyn
    May 13, 2005
  4. prix prad
    Replies:
    4
    Views:
    468
    prix prad
    Nov 21, 2009
  5. polilop
    Replies:
    3
    Views:
    88
    polilop
    Sep 21, 2009
Loading...

Share This Page