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 }); }
There is two method for change border color of dropdownlist in asp.net . In first method you can use System.Drawing.Color.Blue enumeration for changing color.
DropDownList1.BorderColor = System.Drawing.Color.Red;
In Second method you can use DropDownList1.Attributes.Add() method.
DropDownList1.Attributes.Add("style", "value");
Lets take an simple example . Drop one dropdownlist control to the design page and handle SelectedIndexChanged event.
DropDownList1.BorderColor = System.Drawing.Color.Red;
In Second method you can use DropDownList1.Attributes.Add() method.
DropDownList1.Attributes.Add("style", "value");
Lets take an simple example . Drop one dropdownlist control to the design page and handle SelectedIndexChanged event.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList1.Attributes.Add("style", "border-color:" + DropDownList1.SelectedItem.Text);
DropDownList1.BorderWidth = 5;
DropDownList1.BorderStyle = BorderStyle.Dashed;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
Height="22px" onselectedindexchanged="DropDownList1_SelectedIndexChanged"
Width="223px">
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Green</asp:ListItem>
<asp:ListItem>Black</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
Output
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList1.Attributes.Add("style", "border-color:" + DropDownList1.SelectedItem.Text);
DropDownList1.BorderWidth = 5;
DropDownList1.BorderStyle = BorderStyle.Dashed;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
Height="22px" onselectedindexchanged="DropDownList1_SelectedIndexChanged"
Width="223px">
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Green</asp:ListItem>
<asp:ListItem>Black</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
Comments
Post a Comment