Skip to main content

Posts

Featured Post

How to use Tabs in ASP.NET CORE

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 });             }            
Recent posts

Add control dynamically in ASP.NET CORE also save value into Database

public class PersonViewModel     {         public string Name { get; set; }         public string FatherName { get; set; }             } public class PeopleViewModel     {         public List<PersonViewModel> People { get; set; }     } Home Controller  public IActionResult People()         {             return View();         } [HttpPost]         public IActionResult People(PeopleViewModel vm)         {             return View();         } cshtml file @model dynamicTextBox.Models.PeopleViewModel @{     ViewData["Title"] = "People"; } <h2>People</h2> <h4>PeopleViewModel</h4> <hr /> <div class="row">     <div class="col-md-4">         <form asp-action="People">             <div asp-validation-summary="ModelOnly" class="text-danger"></div>             <div class="singlePerson">                

Highlight Table Row based on some Condition in ASP.NET Core

Model Class public class Products     {         public int Id { get; set; }         public string Name { get; set; }         public int Price { get; set; }     } Controller Code  public IActionResult Index()         {             List<Products> p1 = new List<Products>();             p1.Add(new Products { Id = 1, Name = "Samsung", Price = 50 });             p1.Add(new Products { Id = 2, Name = "Samsung1", Price = 50 });             p1.Add(new Products { Id = 3, Name = "Samsung2", Price = 150 });             p1.Add(new Products { Id = 4, Name = "Samsung3", Price = 150 });             p1.Add(new Products { Id = 5, Name = "Samsung4", Price = 550 });             p1.Add(new Products { Id = 6, Name = "Samsung5", Price = 550 });             return View(p1);         } View Section @model IEnumerable<TestingApplication.Models.Products> @{     ViewData["Title"] = "Index"

Implement TreeView in ASP.NET CORE

models  public class City     {         public int Id { get; set; }         public string Name { get; set; }         public int StateId { get; set; }         public virtual State State { get; set; }     }  public class State     {         public int Id { get; set; }         public string Title { get; set; }         public virtual List<City> City { get; set; }     }  public class TreeViewNode     {         public string id { get; set; }         public string parent { get; set; }         public string text { get; set; }     }  Controller Code  [HttpGet]  public IActionResult Index()         {             List<TreeViewNode> nodes = new List<TreeViewNode>();                      //Loop and add the Parent Nodes.             foreach (State type in _context.State)             {                 nodes.Add(new TreeViewNode { id = type.Id.ToString(), parent = "#", text = type.Title });             }             //Loop and add th

Save and Display Binary Images from Database in DataGridView in Windows Forms

In this article, I am going to show you, How to show images in DataGridView in Windows forms c#. Its easy to bind the DataGridView with the database table which is contain binary image. You can check this code to bind the DataGridView with the image using Entity Framework. using System; using System.IO; using System.Linq; using System.Windows.Forms; namespace BankingApplication_Tutorial {     public partial class Form4 : Form     {         public Form4()         {             InitializeComponent();         }         private void Form4_Load(object sender, EventArgs e)         {             dataGridView1.AutoGenerateColumns = false;             dataGridView1.ColumnCount = 2;             dataGridView1.Columns[0].Name = "Id";             dataGridView1.Columns[0].HeaderText = "Image Id";             dataGridView1.Columns[0].DataPropertyName = "Id";             dataGridView1.Columns[1].Name = "Name";             dataGridVie

Step By Step Guide to use WebAPI in ASP.NET CORE WebApplication

If you have to completed your WebAPI then must to know , how to use it in web application.  Now , you can see , how to use WebAPI in WebApplication. WEBAPI Project Step-1 :    Create Model first public class Student     {         public int Id { get; set; }         public string Name { get; set; }     } Step-2 :  Create Data Context Class public class Context : DbContext     {         public Context(DbContextOptions<Context> options) : base(options)         {         }         public DbSet<Student> Students { get; set; }     } Step-3 :  Add Connection String into your Application Setting File {   "ConnectionStrings": {     "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-WebApplication1-6550C064-027F-4939-822B-5B4620D08657;Trusted_Connection=True;MultipleActiveResultSets=true"   },   "Logging": {     "IncludeScopes": false,     "LogLevel": {       "Default&q

Dynamically Add or remove control in asp.net core using JavaScript

If you want to add some controls on your web browser, i mean to say if you want to add controls on run time then you can easily dome with any script control, without using c# code. So, here i used Java Script code to add controls on a page. And your code is Index.cshtml <form method="post">     <div id="firstdiv">         <input type="text" name="testinput" />                 <input type="button" value="add dynamic" onclick="DynamicText()"/>             </div>             <input type="submit" value="submit"/> </form> JS----file function DynamicText() {     var division = document.createElement('DIV');     division.innerHTML = DynamictextBox("");     document.getElementById("firstdiv").appendChild(division); } function DynamictextBox(value) {     return '<div><input type=&q