473,701 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
PerformSubstitu tion = true)]
PageA.aspx (C#)
public string ns = "";

protected void Page_Load(objec t sender, EventArgs e)
{
ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
"MyTest.MyFile. aspx");

}

PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt2.aspx.cs" Inherits="Defau lt2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script language="javas cript" type="text/javascript">
<!--

function Button1_onclick ()
{
window.open(<%= ns%>, "_blank",
"menubar=no,tit lebar=no,toolba r=no,status=no" );
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="javas cript" onclick="return Button1_onclick ()" />
</body>
</html>

MyFile.ascx (stored in resource file)
<%@ Page Language="C#" %>

<html>
<head runat="server">
<title>MyTitl e</title>
</head>
<body bgcolor="#6699c c">
<form id="form1" runat="server">
</form>
</body>

</html>

<script runat="server" type="text/C#">

protected override void OnLoad(EventArg s e)
{
Response.Write( "I am writing to dee page!");
base.OnLoad(e);
}
</script>

Feb 20 '07 #1
13 3551
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" <go********@gma il.comschrieb im Newsbeitrag news:11******** **************@ v33g2000cwv.goo glegroups.com.. .
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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
PerformSubstitu tion = true)]
PageA.aspx (C#)
public string ns = "";

protected void Page_Load(objec t sender, EventArgs e)
{
ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
"MyTest.MyFile. aspx");

}

PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt2.aspx.cs" Inherits="Defau lt2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script language="javas cript" type="text/javascript">
<!--

function Button1_onclick ()
{
window.open(<%= ns%>, "_blank",
"menubar=no,tit lebar=no,toolba r=no,status=no" );
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="javas cript" onclick="return Button1_onclick ()" />
</body>
</html>

MyFile.ascx (stored in resource file)
<%@ Page Language="C#" %>

<html>
<head runat="server">
<title>MyTitl e</title>
</head>
<body bgcolor="#6699c c">
<form id="form1" runat="server">
</form>
</body>

</html>

<script runat="server" type="text/C#">

protected override void OnLoad(EventArg s e)
{
Response.Write( "I am writing to dee page!");
base.OnLoad(e);
}
</script>
Feb 20 '07 #2
On Feb 20, 9:13 am, "Axel Dahmen" <KeenToK...@new sgroup.nospamwr ote:
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" <goodold...@gma il.comschrieb im Newsbeitragnews :11************ **********@v33g 2000cwv.googleg roups.com...
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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
PerformSubstitu tion = true)]
PageA.aspx (C#)
public string ns = "";
protected void Page_Load(objec t sender, EventArgs e)
{
ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
"MyTest.MyFile. aspx");
}
PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt2.aspx.cs" Inherits="Defau lt2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script language="javas cript" type="text/javascript">
<!--
function Button1_onclick ()
{
window.open(<%= ns%>, "_blank",
"menubar=no,tit lebar=no,toolba r=no,status=no" );
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="javas cript" onclick="return Button1_onclick ()" />
</body>
</html>
MyFile.ascx (stored in resource file)
<%@ Page Language="C#" %>
<html>
<head runat="server">
<title>MyTitl e</title>
</head>
<body bgcolor="#6699c c">
<form id="form1" runat="server">
</form>
</body>
</html>
<script runat="server" type="text/C#">
protected override void OnLoad(EventArg s 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.ax...75600008593750

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

Feb 20 '07 #3
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" <go********@gma il.coma écrit dans le message de news:
11************* *********@v33g2 00...legr oups.com...
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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
PerformSubstitu tion = true)]
PageA.aspx (C#)
public string ns = "";

protected void Page_Load(objec t sender, EventArgs e)
{
ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
"MyTest.MyFile. aspx");

}

PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt2.aspx.cs" Inherits="Defau lt2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script language="javas cript" type="text/javascript">
<!--

function Button1_onclick ()
{
window.open(<%= ns%>, "_blank",
"menubar=no,tit lebar=no,toolba r=no,status=no" );
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="javas cript" onclick="return Button1_onclick ()" />
</body>
</html>

MyFile.ascx (stored in resource file)
<%@ Page Language="C#" %>

<html>
<head runat="server">
<title>MyTitl e</title>
</head>
<body bgcolor="#6699c c">
<form id="form1" runat="server">
</form>
</body>

</html>

<script runat="server" type="text/C#">

protected override void OnLoad(EventArg s e)
{
Response.Write( "I am writing to dee page!");
base.OnLoad(e);
}
</script>

Feb 20 '07 #4
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...@gma il.coma écrit dans le message de news:
1171980219.0880 72.326...@v33g2 000cwv.googlegr oups.com...
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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
PerformSubstitu tion = true)]
PageA.aspx (C#)
public string ns = "";
protected void Page_Load(objec t sender, EventArgs e)
{
ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
"MyTest.MyFile. aspx");
}
PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt2.aspx.cs" Inherits="Defau lt2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script language="javas cript" type="text/javascript">
<!--
function Button1_onclick ()
{
window.open(<%= ns%>, "_blank",
"menubar=no,tit lebar=no,toolba r=no,status=no" );
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="javas cript" onclick="return Button1_onclick ()" />
</body>
</html>
MyFile.ascx (stored in resource file)
<%@ Page Language="C#" %>
<html>
<head runat="server">
<title>MyTitl e</title>
</head>
<body bgcolor="#6699c c">
<form id="form1" runat="server">
</form>
</body>
</html>
<script runat="server" type="text/C#">
protected override void OnLoad(EventArg s 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

Feb 20 '07 #5
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...@gma il.coma écrit dans le message de news:
1171980219.088 072.326...@v33g 2000cwv.googleg roups.com...
>>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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
PerformSubsti tution = true)]
PageA.aspx (C#)
public string ns = "";
protected void Page_Load(objec t sender, EventArgs e)
{
ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
"MyTest.MyFil e.aspx");
}
PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Def ault2.aspx.cs" Inherits="Defau lt2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script language="javas cript" type="text/javascript">
<!--
function Button1_onclick ()
{
window.open(< %=ns%>, "_blank",
"menubar=no,t itlebar=no,tool bar=no,status=n o");
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="jav ascript" onclick="return Button1_onclick ()" />
</body>
</html>
MyFile.ascx (stored in resource file)
<%@ Page Language="C#" %>
<html>
<head runat="server">
<title>MyTitl e</title>
</head>
<body bgcolor="#6699c c">
<form id="form1" runat="server">
</form>
</body>
</html>
<script runat="server" type="text/C#">
protected override void OnLoad(EventArg s e)
{
Response.Writ e("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
Feb 20 '07 #6
On Feb 20, 11:22 am, bruce barker <nos...@nospam. comwrote:
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 insidea
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 wouldlike
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 tomind
would be to save this in an ASPX file as usual. Else elaborate on whatyou
are trying to do in case someone would have a simpler approach to suggest...
"Bob Jones" <goodold...@gma il.coma écrit dans le message de news:
1171980219.0880 72.326...@v33g2 000cwv.googlegr oups.com...
>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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
PerformSubstit ution = true)]
PageA.aspx (C#)
public string ns = "";
protected void Page_Load(objec t sender, EventArgs e)
{
ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
"MyTest.MyFile .aspx");
}
PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defa ult2.aspx.cs" Inherits="Defau lt2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script language="javas cript" type="text/javascript">
<!--
function Button1_onclick ()
{
window.open(<% =ns%>, "_blank",
"menubar=no,ti tlebar=no,toolb ar=no,status=no ");
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="java script" 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="#6699c c">
<form id="form1" runat="server">
</form>
</body>
</html>
<script runat="server" type="text/C#">
protected override void OnLoad(EventArg s 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

Feb 20 '07 #7
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.WebC lient 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" <go********@gma il.coma écrit dans le message de news:
11************* ********@s48g20 00...legro ups.com...
On Feb 20, 11:22 am, bruce barker <nos...@nospam. comwrote:
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...@gma il.coma écrit dans le message de news:
1171980219.0880 72.326...@v33g2 000cwv.googlegr oups.com...
>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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
PerformSubstit ution = true)]
PageA.aspx (C#)
public string ns = "";
protected void Page_Load(objec t sender, EventArgs e)
{
ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
"MyTest.MyFile .aspx");
}
PageA.aspx (javascript)
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defa ult2.aspx.cs" Inherits="Defau lt2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<script language="javas cript" type="text/javascript">
<!--
function Button1_onclick ()
{
window.open(<% =ns%>, "_blank",
"menubar=no,ti tlebar=no,toolb ar=no,status=no ");
}
// -->
</script>
</head>
<body>
<input id="Button1" type="button" value="button"
language="java script" 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="#6699c c">
<form id="form1" runat="server">
</form>
</body>
</html>
<script runat="server" type="text/C#">
protected override void OnLoad(EventArg s 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
Feb 20 '07 #8
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.WebC lient 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...@gma il.coma écrit dans le message de news:
1171989383.4688 41.92...@s48g20 00cws.googlegro ups.com...
On Feb 20, 11:22 am, bruce barker <nos...@nospam. comwrote:


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...@gma il.coma écrit dans le message de news:
>1171980219.088 072.326...@v33g 2000cwv.googleg roups.com...
>>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"t ags. 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: WebResourceAttr ibute("MyTest.M yFile.aspx", "text/html",
>>PerformSubsti tution = true)]
>>PageA.aspx (C#)
>>public string ns = "";
>>protected void Page_Load(objec t sender, EventArgs e)
>>{
>>ns = Page.ClientScri pt.GetWebResour ceUrl(GetType() ,
>>"MyTest.MyFil e.aspx");
>>}
>>PageA.aspx (javascript)
>><%@ Page Language="C#" AutoEventWireup ="true"
>>CodeFile="Def ault2.aspx.cs" Inherits="Defau lt2" %>
>><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>"http://
>>>www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
>><html xmlns="http://www.w3.org/1999/xhtml" >
>><head runat="server">
>> <title>Untitl ed Page</title>
>><script language="javas cript" type="text/javascript">
>><!--
>>function Button1_onclick ()
>>{
>>window.open(< %=ns%>, "_blank",
>>"menubar=no,t itlebar=no,tool bar=no,status=n o");
>>}
>>// -->
>></script>
>></head>
>><body>
>><input id="Button1" type="button" value="button"
>>language="jav ascript" onclick="return Button1_onclick ()" />
>></body>
>></html>
>>MyFile.ascx (stored in resource file)
>><%@ Page Language="C#" %>
>><html>
>><head runat="server">
>><title>MyTitl e</title>
>></head>
>><body bgcolor="#6699c c">
>><form id="form1" runat="server">
>></form>
>></body>
>></html>
>><script runat="server" type="text/C#">
>>protected override void OnLoad(EventArg s e)
>>{
>>Response.Writ e("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

Feb 20 '07 #9
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

Feb 20 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
8841
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page (same folder). The cookie is not received. Can someone explain why? I worked around this by adding a cache-control header with a value of no-cache. This fixes the problem. Unfortunately that causes another problem with Internet Explorer...
2
1634
by: learner | last post by:
Hi, In a page, i have many links. I have some functions in a global file which is included in all linked pages. I want to have a reference to a window which is to be opened on clicking one link and it should be known only to one more link on that page and not to other links. I cant have that window reference in that global file, since iam declaring it initially as Null and modifying its value in that one particular link. Since all links...
25
19947
by: chris | last post by:
how would i resize a browser window to a specific size as the page loads, using html or javascript
3
4170
by: w2000 | last post by:
Greeting all, I am studying Javascript to custom my yahoo estore, I need to open a custom sized window in a new browser , I tried the following script on 3 different PCs running XP pro. IE 6, it worked on one and did not work on the other two. Please need your help. Thanks Luka
29
5018
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the window properly but does not pass the parameter. (this is part of a coldfusion template) <a href="##"
28
3044
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
13
2269
by: Richard Shewmaker | last post by:
I've only recently returned to (trying to) doing simple JS, so this is probably a really lame question. I have a Web page with a series of graphics in it (window A). Clicking on a graphic in A opens a small pop-up window (window B) over A. If the visitor clicks on B, it closes. If the visitor clicks back on A -- the page or a new graphic -- A comes
2
2461
by: David | last post by:
Hi All: Here's what may be a confusing question. I have an application which has a basic help window that is attached to a Windows application. It uses IE objects to render html text. The user isn't aware that the basic help window is an IE window since it has no controls on it. Within that window, however, are links to "advanced help" pages which I want to open in a new (full-size) window in the DEFAULT system browser. The problem is...
3
2647
by: Tomasz J | last post by:
Hello Developers! A lot has been written about Java Script window.open() function and lost session state. But the most recent version of IE seems to handle it correctly. But now I have an opposite problem: how to open a new browser window so it *does not* share the session state with the first (parent) window? I have a web application which must open a new popup window, but new session
2
6975
by: Nicole.Winfrey | last post by:
Hi, At the moment, I'm displaying the XML HTTP response text using javascript alert (see below). I'm trying to render XML HTTP response in a new window and the output of the window needs to be of content type text/xml (i.e. the XML output where you can expand/contact the tags in browser). Is there anyway to render the XML? Thanks.... // Post XML via AJAX.
0
8649
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9229
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8977
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7824
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5904
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4410
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2398
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.