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 HtmlForm Class
The HtmlForm class can be used to access the HTML <form> element in the code file. If you add any HTML control to the form using ASP.NET IDE , the web form automatically converts that control into the object of the HtmlForm class. You can also create additional forms using the HtmlForm class, if required. All server controls that postback to the server must be placed between the opening and closing tags of an HTML form. You can use the HTML Form class to get access to the HTML <form> element on the server.This class inherits the HtmlControl class.
Lets take an example
The Html Form class can be used to access the HTML <form> elements in the code file
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Submit1_ServerClick(Object Sender, EventArgs e)
{
ename.InnerHtml = Text1.Value.ToString();
fsub.InnerHtml = Text2.Value.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter Your name: <input id="Text1" type="text" runat ="server" /><br />
Enter your fav. Subject: <input id="Text2" type="text" runat ="server" /><br />
<input id="Submit1" type="submit" value="submit" runat ="server" onserverclick ="Submit1_ServerClick" />
<br />
Your enter name: <span id="ename" runat="server" /> <br />
Your Fav. subject <span id="fsub" runat ="server" />
</div>
</form>
</body>
</html>
<!DOCTYPE html>
<script runat="server">
protected void Submit1_ServerClick(Object Sender, EventArgs e)
{
ename.InnerHtml = Text1.Value.ToString();
fsub.InnerHtml = Text2.Value.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter Your name: <input id="Text1" type="text" runat ="server" /><br />
Enter your fav. Subject: <input id="Text2" type="text" runat ="server" /><br />
<input id="Submit1" type="submit" value="submit" runat ="server" onserverclick ="Submit1_ServerClick" />
<br />
Your enter name: <span id="ename" runat="server" /> <br />
Your Fav. subject <span id="fsub" runat ="server" />
</div>
</form>
</body>
</html>
Output
Comments
Post a Comment