D
David
I have two classes and a web page: test1.cs, test2.cs, and test.aspx.
I know how to add a reference to test1.cs from test.aspx using the
assembly directive (<%@ Assembly Src="test1.cs" %>). This works fine,
but what if test1.cs needs to call a method from test2.cs. How can I
add a reference to test2.cs from test1.cs without compiling either?
--------test.aspx--------
<%@ Page Language="C#"%>
<%@ Assembly Src="test1.cs" %>
<%@ Assembly Src="test2.cs" %>
<script runat="server">
void Page_Load() {
Response.Write(ns1.ClassOne.SomeMethod());
Response.Write("<br>");
Response.Write(ns2.ClassTwo.AnotherMethod());
}
</script>
--------test1.cs--------
namespace ns1 {
public class ClassOne {
public static string SomeMethod() {
return "return from SomeMethod class one";
//How do I call AnotherMethod() from here???
}
}
}
--------test2.cs--------
namespace ns2 {
public class ClassTwo {
public static string AnotherMethod() {
return "return from AnotherMethod class two";
}
}
}
I know how to add a reference to test1.cs from test.aspx using the
assembly directive (<%@ Assembly Src="test1.cs" %>). This works fine,
but what if test1.cs needs to call a method from test2.cs. How can I
add a reference to test2.cs from test1.cs without compiling either?
--------test.aspx--------
<%@ Page Language="C#"%>
<%@ Assembly Src="test1.cs" %>
<%@ Assembly Src="test2.cs" %>
<script runat="server">
void Page_Load() {
Response.Write(ns1.ClassOne.SomeMethod());
Response.Write("<br>");
Response.Write(ns2.ClassTwo.AnotherMethod());
}
</script>
--------test1.cs--------
namespace ns1 {
public class ClassOne {
public static string SomeMethod() {
return "return from SomeMethod class one";
//How do I call AnotherMethod() from here???
}
}
}
--------test2.cs--------
namespace ns2 {
public class ClassTwo {
public static string AnotherMethod() {
return "return from AnotherMethod class two";
}
}
}