MVC,JS
MVC,JS
grep():
This grep() method in jQuery is used to finds the elements of an array that
satisfies a filter function.not affected in original array.
Syntax:
jQuery.grep(array, function(element, index) [, invert])
array:�This parameter holds the array like object for searching.
function(element, index):�It is the filter function which takes two
arguments,�element�which holds the element of the array and�index�which holds the
index of that particular element.
invert:�It is false or not passed, then the function returns an array having all
elements for which �callback� returns true. If this is passed true, then the
function returns an array having all elements for which �callback� returns false.
Filter:
The filter()�method is used to filter out all the elements that do not match the
selected criteria and those matches will be returned.
Syntax:
$(selector).filter(criteria, function(index))
Ajax:
Used to load the data from server side without browser page refresh.
Ajax Syntax:
$.ajax({
type: "POST",
url: "/Home/JqAJAX",
data: JSON.stringify(Student),
dataType: "json"
contentType: 'application/json; charset=utf-8',
success: function(data) {
alert(data.msg);
},
error: function() {
alert("Error occured!!")
}
});
MasterLayout page:
its Located at Shared folder in MVC APPlication
you learn how to create a common page layout for multiple pages in your application
by taking advantage of view master pages
You also can take advantage of view master pages to share common content across
multiple pages in your application.
For example, you can place your website logo, navigation links, and banner
advertisements in a view master page.
That way, every page in your application would display this content automatically
jQuery.map(array,callback)
jQuery.map(object,callback)
Def:
map() Method in jQuery is used to translate all items in an array or object to new
array of items.
--array:Array to translate
--object:object to translate
--Callback:
callback(Object elementOfArray,integer Indexof Array)=>Boolean
callback: This parameter holds the function to process each item against.
jQuery Array.Map
Note: map() does not execute the function for array elements without values.
Note: this method does not change the original array.
Filter:$(selector).filter(criteria, function(index))
Def:
filter() method is used to filter out all the elements that do not match the
selected criteria and those matches will be returned.
<html>
<head>
<title>GEEKS FOR GEEKS ARTICLE</title>
<script src="https://ajax.googleapis.com/ajax/libs/
jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("li").filter(".first, .last").css("color", "red")
.css("backgroundColor", "yellow");
});
</script>
</head>
<body>
<ul>
<li class="first">GeeksForGeeks</li>
<li class="first">GeeksForGeeks</li>
<li class="middle">GeeksForGeeks</li>
<li class="last">GeeksForGeeks</li>
<li class="last">GeeksForGeeks</li>
</ul>
</body>
</html>
HTML Helpres :
--Just Like a Web Forms control in ASP.Net,HTML Helpers used to modify HTML
Page ,it is morlight weight
In Most of the method HTML helpers return as string, In MVC you can create own HTML
Helpers or Use Built in HTML helpers
Ouput Cache:
We need caching in many different scenarios to improve the performance of an
application
Purpouse:
you can take advantage of the output cache to avoid executing a database query
every time a user invokes the same controller action.
In this case, the view will be retrieved from the cache instead of being
regenerated from the controller action.
Caching enables you to avoid performing redundant work on the server
[OutputCache(Duration = 60)]
public ActionResult Index(){
var employees = from e in db.Employees
orderby e.ID
select e;
return View(employees);
}
Bundling :
Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine or bundle
multiple files into a single file.
You can create CSS, JavaScript and other bundles. Fewer files means fewer HTTP
requests and that can improve first page load performance
Bundling and Minification provide us a way to both reduce the number of requests
needed to get JS and CSS resource files and reduce the size of the files
themselves,
thereby improving the responsiveness of our apps.
Purpouse:
They are nice little optimizations for our MVC apps that can improve performance
and add responsiveness.
session :
MVC the controller decides how to render view, meaning which values are accepted
from View and which needs to be sent back in response.
ASP.NET MVC Session state enables you to store and retrieve values for a user when
the user navigatesto other view in an ASP.NET MVC application.
Purpouse:
MVC provides three ways (TempData, ViewData and ViewBag) to manage session, apart
from that we can use session variable, hidden fields and HTML controls for the
same.
But like session variable these elements cannot preserve values for all requests;
value persistence varies depending the flow of request.
session Storage Format:
Session stores the data in key and value format. Value gets stored in object
format, so any type of data (string, integer, class collection etc.)
Routing :
Def:Routing is a mechanism in MVC that decides which action method of a controller
class to execute.
Without routing there's no way an action method can be mapped. to a request.
Routing is a part of the MVC architecture so ASP.NET MVC supports routing by defaul
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Student",
url: "students/{id}",
defaults: new { controller = "Student", action = "Index"}
);
Web API Routing:
Web API routing is similar to ASP.NET MVC Routing. It routes an incoming HTTP
request to a particular action method on a Web API controller.
Web API supports two types of routing: Convention-based Routing. Attribute Routing.
public static void Register(HttpConfiguration config)
{
// Enable attribute routing
config.MapHttpAttributeRoutes();
LINQ:
LINQ stands for Language Integrated Query.
LINQ is a data querying API that provides querying capabilities to .NET
languages with a syntax similar to a SQL.
LINQ queries use C# collections to return data.
LINQ in C# is used to work with data access from sources such as objects, data
sets, SQL Server, and XML.
1.Standardized way of querying multiple data sources : The same LINQ syntax
can be used to query multiple data sources.
2.Compile time safety of queries : It provides type checking of objects at
compile time.
3.Readable code : LINQ makes the code more readable so other developers can
easily understand and maintain it.
Types of LINQ:
LINQ to Objects.
LINQ to XML(XLINQ)
LINQ to DataSet.
LINQ to SQL (DLINQ)
LINQ to Entities.
Advantages of LINQ :
It offers Syntax Highlighting to find out errors during Design time.
Write queries easily
Development time is reduced.
Easy debugging
Transformation of data from one to another easily like SQL to XML