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 }); }
Example of Web User Control
Step-1 : Add Web User Control file in solution explorer name as " WebUserControl.ascx".
Step-2 : Drop some controls from tool box to Designing window of WebUserControl.ascx page .
Step-1 : Add Web User Control file in solution explorer name as " WebUserControl.ascx".
Step-2 : Drop some controls from tool box to Designing window of WebUserControl.ascx page .
Step-3 : Add a Web form in Solution explorer name as " usercontroluses.aspx"
Step-4 : Drop "WebUserControl.ascx " page from solution explorer to Web form ( usercontroluses.aspx)
Step-5 : Check your Web Form designing part .
After dropping your web form contain a single Register directive and one user defined tag.
<%@ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>
<uc1:WebUserControl ID="WebUserControl1" runat="server" />
Code file of WebUserControl.ascx<uc1:WebUserControl ID="WebUserControl1" runat="server" />
<%@ Control Language="C#" ClassName="WebUserControl" %>
<script runat="server">
</script>
<asp:Label ID="Label1" runat="server" Text="UserName"></asp:Label>
:
<asp:TextBox ID="TextBox1" runat="server" Width="189px"></asp:TextBox>
<p> </p>
<p> Password :
<asp:TextBox ID="TextBox2" runat="server" Width="192px"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="Submit " />
</p>
Code file of usercontroluses.aspx<script runat="server">
</script>
<asp:Label ID="Label1" runat="server" Text="UserName"></asp:Label>
:
<asp:TextBox ID="TextBox1" runat="server" Width="189px"></asp:TextBox>
<p> </p>
<p> Password :
<asp:TextBox ID="TextBox2" runat="server" Width="192px"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="Submit " />
</p>
<%@ Page Language="C#" %>
<%@ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>
<!DOCTYPE html>
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:WebUserControl ID="WebUserControl1" runat="server" />
</div>
</form>
</body>
</html>
<%@ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>
<!DOCTYPE html>
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:WebUserControl ID="WebUserControl1" runat="server" />
</div>
</form>
</body>
</html>
Comments
Post a Comment