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 }); }
The HtmlAnchor Class
The HtmlAnchor class is used to create an anchor, <a>, element for navigation. This class can be used for the following purpose:Navigation- You can use the Href property and provide the address of anchor website, where you want to take the user . Alternatively , you can also take the user at a different location of the same page.
Handling events : You can handle the events of this class , such as the ServerClick event, to programmatically perform the desired actions, when user interacts with the anchor <a> element.
This HtmlAnchor class gives you access to the HTML <a> tag in server code.
Event of the HtmlAnchor Class
ServerClick : Occurs when the user clicks an Anchor control in the browser, This event is handled in the server.Example of How to access anchor tag in code file in ASP.NET
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void anchor1_ServerClick(object sender, EventArgs e)
{
anci.InnerHtml = " welcome to anchor tag";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<a id="anchor1" runat ="server" onserverclick ="anchor1_ServerClick">Click here</a>
<br />
<span id="anci" runat ="server" ></span>
</div>
</form>
</body>
</html>
Output
<!DOCTYPE html>
<script runat="server">
protected void anchor1_ServerClick(object sender, EventArgs e)
{
anci.InnerHtml = " welcome to anchor tag";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<a id="anchor1" runat ="server" onserverclick ="anchor1_ServerClick">Click here</a>
<br />
<span id="anci" runat ="server" ></span>
</div>
</form>
</body>
</html>
Comments
Post a Comment