Monday, February 29, 2016


jQuery is a very powerful client-side JavaScript library for Web applications. It provides an lightweight, elegant way to quickly access and manipulate the HTML Document Object Model (DOM), to communicate with server-side web services, and to create animations in the browser without the need for heavier client side technologies.

Overview of jQuery

    • Its History and Features
    • General tips, gotchas, and best practices for ASP.NET Applications
      How can you use jQuery?

    • To provide better user experiences and to create custom controls
    • To ultimately write LESS code
      Sample Controls and Demos

    • Custom Navigation Control
    • jQuery DataTables
    • jQueryValidation
      JavaScript has not always been easy or very fun to work with.

  • A large issue with that comes from the various DOM specifications that different browsers used for HTML,  but not the JavaScript itself.
    For the most part, ASP.NET UI Controls help us to avoid working  extensively with the DOM and JavaScript.

  • Example: Server-side PostBack events raised from changes in the state of the page controls.
    Write less. Do more.
    Quickly access, manipulate, and traverse HTML documents with a lot LESS effort.
    Microsoft is actively supporting it in MVC3 and the ASP.NET 4 jQuery Templating Engine.
    Key Features of jQuery
    CCS3 Selectors
    Typically you will access elements based on a class or an id,
     but there are also other psuedo-selectors available (:visible, :first, :input). Find all of them here:
    DOM Manipulation
    This is especially helpful if you need to hide and show elements or when you receive a response from an AJAX response payload.
    Utilize a set of built-in jQuery animations or roll your own effects.
    AJAX Communication
    Simple HTTP communication interface with JSON and XML based web services.
    There are NUMEROUS open source plugins available for different needs. That being said, be careful what you use.
    Cross Browser Compatibility
    The jQuery codebase regardless of browser.
    Prerequisites for jQuery
    Get to know CSS and HTML
    If you are trying to animate things or to create your own UI controls, you should understand how CSS and HTML work.
    The biggest things you can learn are how to work with
     position, margin, padding, float, and display properly in HTML.
    Learn to love Firebug for Mozilla Firefox
    It is one of the best web developer tools available you don’t have to pay for.
    Learn to think in Sets and Events
    A selector returns a set of element that your jQuery code will operate over
    This will hide all of the H1 tags in your HTML page
    Beware operating over LARGE sets, this can cause your browser to become unresponsive or you can even crash your browser.
    A elements of the DOM have events which you can subscribe to with event handlers
    $ (“a”).click(function(event){
                    alert (“You clicked a link!”);
    Best Practices
    Managing State with AJAX
    Selectors for ASP.NET Controls
    Debugging Tips
    Managing State with AJAX
    Most tutorials and documentation will prescribe that you initialize all of your jQuery code in an event that handles to document.
    function initControls(){
                    //your init code here
    However, this becomes a problem when you are using AJAX UpdatePanels, because the $(document).ready() will not fire after the call to the server has been completed.
    Any changes that the initControls() function made to the DOM within the UpdatePanel are erased. This includes any event handling you set up.
    So what is the solution to this problem?
    Sys.WebForms.PageRequestManager to the Rescue!
    This class manages partial-page rendering in ASP.NET pages.
    It comes with client-side events that you can subscribe to.
    var requestManager = Sys.WebForms.PageRequestManager.getInstance();
    function initControls(){
                    //your init code here
    function endRequestHandler(sender, args){
                    //still need to do the initial init
    Now we can deal with the UpdatePanel partial-page rendering and still have our jQuery.
    Managing State with AJAX
    The full list of PageRequestManager events with descriptions:

PageRequestManager Event
Raised before processing of the asynchronous request starts. You can use this event to cancel a postback.
Raised before processing of an asynchronous postback starts and the postback is sent to the server. You can use this event to set request headers or to begin an animation that indicates that the page is processing.
Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. You can use this event to provide a custom transition effect for updated content.
Raised after all content on the page is refreshed, as a result of either a synchronous or an asynchronous postback. You can use this event to provide a custom transition effect for updated content.
Raised after an asynchronous postback is finished and control has been returned to the browser. You can use this event to provide a notification to users or to log errors.


Selectors for ASP.NET Controls

If you need to grab an TextBox by its ID, you would undoubtedly think that this will work just fine:


  • However, it might not always.
  • The Problem: In ASP.NET, the INamingContainer appends identifiers to the controls so that it can uniquely reference a control.
  • To get around this, you can use the following:

  • This will look for all elements (*) with txtBox at the end of it.
  • Keep in mind, that this is not a good solution for controls in a Repeater, but you should be using a class to reference these controls anyways, since they are not unique.
    Debugging Tips
    jQuery errors aren’t always the easiest to spot. When a call error occurs, any jQuery and JavaScript below it will not run so that might be your best indicator.
    To debug your code, use Mozilla Firefox in combination with Firebug.

    • Check to make sure all of the files are getting loaded properly.
    • Make sure that you’re not loading libraries twice and that all libraries are loaded in the proper dependency order. jQuery should be your first JavaScript file.
    • Make sure all plugins are in-synch with your chosen jQuery library code.
    • Step through your code in Firebug and use the watch variables. Don’t step into your jQuery code very deeply, because the problem is most likely in your own code.
    • Sometimes, an alert statement is just what you need to glean a better understanding.
      Custom Navigation Control
      jQuery DataTables
      jQuery Validation

Thursday, February 25, 2016

oops Interesting....

Abstract class
we can not declare a static method in an interface, because interfaces have no implementation.
public interface Iproduct
static void test();
declare a method as static in an abstract class,
 because abstract classes can have implementations of static methods
ex: public static void test()
Thus by above point :interface cannot implement methods
abstract class can implement methods
An interface cannot contain fields, constructors, or destructors and it has only the property's signature but no implementation.
An abstract class can contain fields, constructors, or destructors and implement properties
Based on above point, we can say ,:Thus a class may inherit several interfaces but only one abstract class.
A class implementing an interface has to implement all the methods of the interface
but the same is not required in the case of an abstract Class.
No access modifiers are allowed in Interface
Various access modifiers such as abstract, protected, internal, public, virtual, etc. are useful in abstract Classes

Abstract classes are faster than interfaces.


Sealed class



public sealed class classSealed


 // Class members here.

 public string ID;

 public double Price;



A sealed class cannot be used as a base class.

For this reason, it cannot also be an abstract class.

Sealed classes are primarily used to prevent derivation.

Because they can never be used as a base class, some run-time optimizations can make calling sealed class members slightly faster.

Sealing a method means one cannot override it.

 In C# structs are implicitly sealed; therefore, they cannot be inherited.


Ex:Humanàmale class,female class(Here we can say male and female classes are sealed)

public class TestClass : classSealed




In C# a method can not be declared as sealed.

However when we override a method in a derived class, we can declare the overridden method as sealed as shown below.

By declaring it as sealed, we can avoid further overriding of this method.

public class testClass


 public int x;

 public int y;

 public virtual void testMethod(){



 public class TestClass: testClass


 public override sealed void testMethod(){




Prove that only 1 instance of the object is created for static classes?

static constructor:only one 1 instance of the object is  created then this constructor should run only once.

Static class:we can define static memebers(like public static int icount)

if we invoked the method twice/but constructor will fire only once.

public static class Staticclasses
    public static int icount;
    static Staticclasses()

    static void somemethod()
    { }


What is the use of private constructor ? This is used for utility classes

1.a class with a private constructor can not be inherited

2. we can not create a object of the class which has private constructor
3. many times we do not want to create instances of certain classes like utility ,common routine classes

public class class1
private class1()
public static string getdata()
return "hello"

Client can use by using:

string str=class1.getdata()  (SO we are not create instance,we can access method)

Can we define abstract class as a static?

never forget  we can never define abstract class as static

What is the use of c# (Csharp) Shadowing ?

shadowing is replaces current element of the parent where as override is replace the implementations(it does not replace data type or (datatype /datamethod)

namespace Abstract_encapsulation
    public class customer
        //step1:what does customer(Abstraction)//show only what is neccessary
        //step3:made complicated method as private (Encapuslation):means reduce the complexity/hide complexity to client

        public string customercode = "";
        public string customername = "";
        //public void Add()



        //public bool validate()
        //    //cust code and name
        //    return true;
        //public bool createDbobjects()
        //    return true;

        //Now simplified to expose to clients

        public void Add()
        private bool validate()
            //cust code and name
            return true;
        private bool createDbobjects()
            return true;


Inline image 1

Inline image 2