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 you are generating error message to the client side then you can use any type of validation in given ToolBox such as RequiredField validator , compare validator , custom validator etc. If you want to use Image for easy understand then you should insert image in Text property of the validation control.
<asp:RequiredFieldValidator ControlToValidate ="TextBox1" Text="<img width='40px' height='40px' src='error.jpg' />" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
Here we have used HTML Image Tag inside Text property of control.
Example
Output
<asp:RequiredFieldValidator ControlToValidate ="TextBox1" Text="<img width='40px' height='40px' src='error.jpg' />" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
Here we have used HTML Image Tag inside Text property of control.
Example
<%@ Page Language="C#" %>
<!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>
<asp:TextBox ID="TextBox1" runat="server" Width="201px"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate ="TextBox1" Text="<img width='40px' height='40px' src='error.jpg' />" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Check RequiredField" />
</div>
</form>
</body>
</html>
<!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>
<asp:TextBox ID="TextBox1" runat="server" Width="201px"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate ="TextBox1" Text="<img width='40px' height='40px' src='error.jpg' />" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Check RequiredField" />
</div>
</form>
</body>
</html>
Output
Comments
Post a Comment