I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
In this article i will learn how to get the page name in asp.net. If you are using visual studio 2005 to 2010 then url show page name with extension. But if you are using vs2012 to vs2015 then do not show. Lets check the example of get page name from page url.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Get the page name program in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Get Page Name" OnClick="Button1_Click" />
<br />
<br />
<asp:Label ID="lblresult" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
Code Behind
using System;
using System.IO;
public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string pagename = Path.GetFileName(Request.Path);
lblresult.Text = pagename;
}
}
Code generate the following output
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Get the page name program in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Get Page Name" OnClick="Button1_Click" />
<br />
<br />
<asp:Label ID="lblresult" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
Code Behind
using System;
using System.IO;
public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string pagename = Path.GetFileName(Request.Path);
lblresult.Text = pagename;
}
}
Code generate the following output
Comments
Post a Comment