You need to call the test class in page.aspx by adding
Using _test; namespace.
and then create an object of class and call the methods using that class.
Refers the simmiller example for your refarence.
test.cs class with namespace _test.
namespace _test
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for test
/// </summary>
public class test
{
public test()
{
//
// TODO: Add constructor logic here
//
}
public string displayName(string message)
{
string msg = "HI " + message;
return msg;
}
public int Increament(int i)
{
return ++i;
}
}
}
page.aspx Design
<form id="form1" runat="server">
<div>
Enter NAME :
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<br />
<br />
Enter Number :
<asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnsubmit" runat="server" OnClick="Submit" Text="Display" />
<br />
<br />
Name :<asp:Label ID="lblName" runat="server"></asp:Label>
<br />
<br />
Number :
<asp:Label ID="lblNumber" runat="server"></asp:Label>
</div>
</form>
page.aspx.cs
In cs file you need to use _test namespace by adding
using _test;
Also need to create object of test class. then you can call methods or properties of test class using that object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using _test;
public partial class page : System.Web.UI.Page
{
protected void Submit(object sender, EventArgs e)
{
DisplaynameAndNumber();
}
protected void DisplaynameAndNumber()
{
test test = new test();
lblName.Text = test.displayName(txtname.Text);
lblNumber.Text = test.Increament(Convert.ToInt32(txtNumber.Text)).ToString();
}
}