Posts

Showing posts from January, 2014

Problem using $.ajax method of jquery

When we use $.ajax method then sometime we use this in side success method we get unexpected error because in $.ajax method in success property this has different meaning it refers to xmlhttprequest object other then we are expecting. Here is an example and solution for that: Example:     $("#location").change(function () {             if ($(this).val() == "-1") {                 $("#category").prop('disabled', 'disabled');             }                     var that = this;             $.ajax({                 type: "POST",                 url: "/Home/Category",                 data: JSON.stringify({ projectId: $("#project").val(), locationId: $(this).val() }),  ...

CSS property selector using jQuery

We can not directly select element using css property values but to do that we can use filter method of jquery var myDiv = $('div').filter(function () { return this.style.opacity == '0.9' }); This will select all div which has css opacity value 0.9

Create custom paging in ASP.NET MVC

Image
Sometimes we require to create custom paging in asp.net mvc application to do that we can use pager. Follow below steps: 1.)Go to package manager and download two packages: 2.) Go to controller and add following code. a) Add using PagedList; in top. b)Write your query as     var person = (from p in personList                           select p).ToPagedList(page, 10); here ToPagedList method takes two parameter first one page number and second page size. Complete code for a\controller action method is :  List<Person> personList = new List<Person>();         public ActionResult Index(int page = 1)         {             personList.Add(new Person                 {                     Id = 1,       ...