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 }); }
How to get the element from the html file using their id and class property. In my previous article we have already get the html element from their id property. But in this article we will get the element from their class name. Lets take a simple example to demonstrate the article.
<%@ Page Language="C#" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.10.2.js"></script>
<script>
$(function(){
$('#Button1').click(function () {
var firstdiv = $('#first').html();
alert(firstdiv);
var getclass = $('.test').html();
alert(getclass);
});
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="first" style="border: 1px solid #009900; padding: 10px">
Welcome to my website
</div>
<div style="border: 1px solid #00ffff; padding: 10px" class="test">
Get This Text By class
</div>
<input id="Button1" type="button" value="Get Element By Id" />
</form>
</body>
</html>
When we click on the button a alert message have to generate with some message. Using html () method we can get the text of the tag.
<%@ Page Language="C#" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.10.2.js"></script>
<script>
$(function(){
$('#Button1').click(function () {
var firstdiv = $('#first').html();
alert(firstdiv);
var getclass = $('.test').html();
alert(getclass);
});
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="first" style="border: 1px solid #009900; padding: 10px">
Welcome to my website
</div>
<div style="border: 1px solid #00ffff; padding: 10px" class="test">
Get This Text By class
</div>
<input id="Button1" type="button" value="Get Element By Id" />
</form>
</body>
</html>
When we click on the button a alert message have to generate with some message. Using html () method we can get the text of the tag.
Comments
Post a Comment