B
Bob Jones
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>
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>