Is there a method to retrieve the file name of a class?

Posted by Dran Dane on Stack Overflow See other posts from Stack Overflow or by Dran Dane
Published on 2010-06-09T14:27:50Z Indexed on 2010/06/09 14:42 UTC
Read the original article Hit count: 142

Filed under:
|

Hello

Is there a method to retrieve the file name of a class?

Specifically I would like to create a static method (CreateLink) in a base class (BasePage) to automatically return the path and filename of the page called.

I code in .C# ASP.NET

private const string TEMPLATE =
    "~/One.aspx";

public static HyperLink CreateLink()
{
    HyperLink link = new HyperLink();
    link.Text = "Click here";
    link.NavigateUrl = String.Format(TEMPLATE);
    return link;
}

Is it possible to avoid the use of TEMPLATE hardcoded variable? Is it possible to retrieve the One.aspx path from file name and location?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET