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 }); }
If your controls are enable then you take some action onto the controls such as checked or unchecked CheckBox and If they are disable then you don't take some action onto the controls.
In previous example we saw checked property of checkbox control .
In previous example we saw checked property of checkbox control .
Example of Dynamically Enable or Disable ASP.NET Controls
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button2_Click(object sender, EventArgs e)
{
Button1.Enabled = true;
CheckBox1.Enabled = true;
RadioButton1.Enabled = true;
TextBox1.Enabled = true;
}
protected void Button3_Click(object sender, EventArgs e)
{
Button1.Enabled = false;
CheckBox1.Enabled = false;
RadioButton1.Enabled = false;
TextBox1.Enabled = false;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button Control" />
<br />
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Text="CheckBox Controls" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Width="164px">TextBox Control</asp:TextBox>
<br />
<br />
<asp:RadioButton ID="RadioButton1" runat="server" Text="Radio Button Control" />
<br />
<br />
<br />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Controls Enable" />
<asp:Button ID="Button3" runat="server" Text="Controls Disable" OnClick="Button3_Click" />
</div>
</form>
</body>
</html>
Output
<!DOCTYPE html>
<script runat="server">
protected void Button2_Click(object sender, EventArgs e)
{
Button1.Enabled = true;
CheckBox1.Enabled = true;
RadioButton1.Enabled = true;
TextBox1.Enabled = true;
}
protected void Button3_Click(object sender, EventArgs e)
{
Button1.Enabled = false;
CheckBox1.Enabled = false;
RadioButton1.Enabled = false;
TextBox1.Enabled = false;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button Control" />
<br />
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Text="CheckBox Controls" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Width="164px">TextBox Control</asp:TextBox>
<br />
<br />
<asp:RadioButton ID="RadioButton1" runat="server" Text="Radio Button Control" />
<br />
<br />
<br />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Controls Enable" />
<asp:Button ID="Button3" runat="server" Text="Controls Disable" OnClick="Button3_Click" />
</div>
</form>
</body>
</html>
Comments
Post a Comment