I can get current method name, but currently I can't get really current class name.
From reference: C# getting its own class name, accepted answer is this.GetType().Name
.
Test.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string currentMethodName = MethodBase.GetCurrentMethod().Name; // "Page_Load"
string currentClassName1 = this.GetType().Name; // "test_test_aspx" // How to get "Test" only?
string currentClassName2 = this.GetType().FullName; // "ASP.test_test_aspx" // How to get "Test" only?
}
}
}