Posts

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,       ...

Access Violation Exception

In the .NET 4.0 and later  Access Violation Exception exception is not handled by try catch block we need to enable it from configuration file by writing <configuration> <runtime> <legacyCorruptedStateExceptionsPolicy enabled="true" /> </runtime> </configuration>   or we can set attribute value in method which contains catch block System.Runtime.ExceptionServices . HandleProcessCorruptedStateExceptionsAttribute

asp.net server control

Image
this post will show you how to create asp.net web server control. First You need to create a project asp.net server control project we can also create server controls by crating controls library. next step is to create some property this code will help you using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace MyServerControl { [DefaultProperty("Text")] [ToolboxData(" ")] public class ShriLinkButton : WebControl { public ShriLinkButton() : base(HtmlTextWriterTag.A) { } private string url; [Bindable(true)] [Category("Appearance")] [DefaultValue("")] [Localizable(true)] public string Url { get { return url; } set { ...