Page component with namespace (C#)
<%@ page src="MyFirstComponent.cs" %>
<%@ Import Namespace="MyComponents" %>
<html>
<head><title>My First Component Example</title></head>
<body>
Our component says: <br /> <br />
<asp:Label id="label1" runat="server" />
<script language="c#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
HelloCS CSComponent = new HelloCS();
label1.Text = CSComponent.SayHello();
}
</script>
</body>
</html>
<%-- MyFirstComponent.cs
namespace MyComponents {
public class HelloCS {
public string SayHello() {
return "Hello World - I'm a C# component!";
}
}
}
--%>
Related examples in the same category