ASP.Net/Language Basics/Namespace
Page component with namespace (C#)
<source lang="csharp">
<%@ page src="MyFirstComponent.cs" %>
<%@ Import Namespace="MyComponents" %>
<html>
<head><title>My First Component Example</title></head>
<body>
Our component says:
<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!"; } }
} --%>
</source>