Simple C# source file is:
using System;
namespace Hello
{
class HelloName
{
public void GiveGreeting(string name){
Console.WriteLine("Hello "+name);
}
public string getGoodWish(string name){
return "Good morning "+name;
}
}
}
This C# source file will be compiled into dll using command csc /target:library HelloName.cs,
The method getGoodWish in class HelloName will be called in an aspx page like the following code.
aspx code is:
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="Hello" %>
<script runat="server">
void Page_Load()
{
if (IsPostBack)
{
Hello.HelloName hello=new Hello.HelloName();
lblJoinedText.Text = hello.getGoodWish("friend");
}
}
</script>
<html>
<head>
<title>Chapter 5 : Using Functions Which Return Values</title>
</head>
<body>
<form runat="server">
<asp:TextBox id="txtIn1" runat="server"></asp:TextBox>
<br />
<asp:TextBox id="txtIn2" runat="server"></asp:TextBox>
<br />
<asp:Button id="Button1" runat="server" Text="Submit"></asp:Button>
<br />
Function used in a variable: <asp:Label id="lblDisguised" runat="server"></asp:Label>
<br />
Function used as value for an object property: <asp:Label id="lblJoinedText" runat="server"></asp:Label>
<br />
Function used as an argument in another function: <asp:Label id="lblJoinedAndBlanked" runat="server"></asp:Label>
<br />
Function used as an expression: <asp:Label id="lblCompareLengths" runat="server"></asp:Label>
</form>
</body>
</html>
My question is: I can't call the dll correctly, which step I made a mistake ?
where do I put the dll file ? So let IIS can find it?
Thanks for any valuable advice.