Here we discuss about how to get current page title name?
When we use below code: protected void Page_Load(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Page.Title))
{
string path = Path.GetFileName(Request.Path);
}
}
Example:
When you use this below code:
protected void Page_Load(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Page.Title))
{
//To get path as a string.
string path = Path.GetFileNameWithoutExtension(Request.Path);
//To get and set page title.
Page.Title = Path.GetFileNameWithoutExtension(Request.Path);
}
}
No comments:
Post a Comment