Posts

Showing posts from September, 2020

Bootstrap Tabs with Example

Image
This article is going to explain how to create a Bootstrap tab with a small example. Step 1: Add CDN To use Bootstrap or jQuery you need to add a CDN link or you can download and use the package. The following is a list of CDN links to use the Bootstrap styles and scripts. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> Step 2: Tab Menu You must use an unordered list element to create the tab menu. In the following code, you will find an unordered list with three menu list items. nav nav-tabs classes are added to the unordered list to convert the list item to the tab menu. The first menu mostly always be active, so in the first list item, the active class is include

Pass the Selected Values ​​of the ListBox from View to Controller in ASP.NET Core Using jQuery Ajax

Image
This article describes how to pass/send the selected ListBox value to the controller using jQuery Ajax. Let's see it through 4 steps. Step 1: Controller The following is a controller code. Microsoft.AspNetCore.Mvc.Rendering is included to use the SelectListItem class. The controller has two action methods, Index() and SampleViewModel() . In the code, a list of movie names is sent to the viewer to bind to the list box. The SampleViewModel() method retrieves the selected movie ID and text and sends it to the results view. HomeController.cs using Microsoft.AspNetCore.Mvc.Rendering; public class HomeController : Controller {    public IActionResult Index()     {         List<SelectListItem> MoviesList = new List<SelectListItem>         {             new SelectListItem { Value = "1", Text = "Zootopia" },             new SelectListItem { Value = "2", Text = "Moana" },             new SelectListItem { Value = "3&q

Pass the Selected Values ​​of the ListBox to Controller in ASP.NET Core

Image
This blog explains how to send selected values of ListBox to ASP.NET Core Controller. Let's look at this with an example. The following is the SampleViewModel class. It has two properties, Movies, and SelectedMovies. The property called Movies will bind the list of movies in the ListBox and the selected movie property will send the selected value from the view to the controller. SampleViewModel.cs using Microsoft.AspNetCore.Mvc.Rendering; public class SampleViewModel {    public List<SelectListItem> Movies { get; set; }    public string[] SelectedMovies { get; set; } } The following is a controller code. Microsoft.AspNetCore.Mvc.Rendering namespace is included to use SelectListItem. The list of movies is assigned to the MoviesList variable. That MoviesList is assigned to the Movies property in the SampleViewModel. Finally, SampleViewModel is sent to view. In the Result action method, the selected list is retrieved from the view and sent to the Result view t

SQL Server LEAD() Function

Image
This blog is going to illustrate the functionality of SQL LEAD() and how to use it. The SQL LEAD () function gives the next row of data for the offset value. This functionality was introduced in SQL Server 2012. Let’s see how to use it. The following is the SampleTable. SELECT SampleID, [Year], Profit FROM SampleTable The following query illustrates how to use the LEAD() function. SELECT SampleID, Year, Profit, LEAD(Profit, 1) OVER (ORDER BY SampleID ASC) AS NextYearProfit FROM SampleTable The following image is the output of the query above. Here you will find the column NextYearProfit. This shows the next profit. Default Value In the previous example, you can see that the last NextYearProfit column value is null. You can set the default value instead of zero if you want. SELECT SampleID, [Year], Profit, LEAD(Profit, 1, 7000000) OVER (ORDER BY SampleID ASC) AS NextYearProfit FROM SampleTable In the image below you can see that the las

SQL Server LAG() Function

Image
This blog is going to illustrate the functionality of SQL LAG() and how to use it. The SQL LAG() function gives the previous row data of the offset value. This functionality has been introduced on the SQL Server 2012. The following is the sample table. There are three columns in table SampleID, Year, and Profit. Let’s see how to get the previous row value.  SELECT * FROM SampleTable The following is an example of the SQL query LAG() function. The query explains how to get the previous year’s profit. SELECT SampleID, Year, Profit,  LAG(Profit, 1) OVER (ORDER BY SampleID ASC) AS PreviousProfit  FROM SampleTable The following table shows the output of the query above. You can see the new column called PreviousProfit here. The first row of the PreviousProfit column is null because there is no previous value. Default value When using the LAG() function, the first result will be null. But it can be assigned a default value. In the following query, the default value is adde