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 }); }
Note : Event occurs only when the AutoPostBack property of the control is set to true.
Example of TextChanged event of the TextBox when AutoPostBack property is set to true.
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox1.Text);
int b = Convert.ToInt32(TextBox2.Text);
int c = a + b;
TextBox3.Text = Convert.ToString(c);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter first number:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
Enter Second Number :
<asp:TextBox ID="TextBox2" runat="server" OnTextChanged="TextBox2_TextChanged" AutoPostBack="True"></asp:TextBox>
<br />
Total : <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
<!DOCTYPE html>
<script runat="server">
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox1.Text);
int b = Convert.ToInt32(TextBox2.Text);
int c = a + b;
TextBox3.Text = Convert.ToString(c);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter first number:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
Enter Second Number :
<asp:TextBox ID="TextBox2" runat="server" OnTextChanged="TextBox2_TextChanged" AutoPostBack="True"></asp:TextBox>
<br />
Total : <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
first enter any number into first Textbox after press TAB key
and enter second number again press TAB key , Your result will show after pressing tab key.
Comments
Post a Comment