Franc Stratton's .NET (TM) Web Application, OOP, and SOA Architecture & Programming Site

A site devoted to ASP.NET (TM), SilverLight (TM) and Browser-Based WPF (TM) Applications, IIS Services, and OOP Architectures

Home     .NET Security     Standards     Data Store     Windows Form Apps     WF/WCF/WPF     jQuery     C# Developer Corner     Java Development     Site Map      
jQuery Basics for ASP.NET
jQuery Selectors
jQueryEvents
Event Handler Methods
jQuery Special Effects
Simple Page Styling
jQuery Callbacks
jQuery Page Method
jQuery Data Method
Simple Dirty Flag
Advanced Dirty Flag
AJAX Call to Web Service
jQuery Events Handlers  Methods for ASP.NET Applications

 

jQuery event handler methods add or remove event handlers from selected form elements. For example:

 

$(selector).bind(event)

 

 MethodFormat  ExampleDescription 

 bind

 $(selector).bind(event)

$('#txtBind1').bind('mouseover', function () {

$("#txtBind1").css("background-color", "#DEB887");

});

$('#txtBind1').bind('mouseleave', function () {

$("#txtBind1").css("background-color", "#CD853F");

});

 This handler method is the main way developers can attach behavior to a document for all jQuery event types. The example binds the mouseover and mouseleave

 background color change  to every textbox on the ASP.NET form.

 unbind $(selector).unbind(event)

 

function UnbindMouseLeave() {

   $('("#txtBind1).unbind('mouseleave');

}

 

 This handler method allows developers  to unattach behavior to a document for all jQuery event  types. The example unbinds the mouseover background color change from every textbox on the ASP.NET form when function called.

 live

 $(selector).live(event type, handler)

OR 

$(selector).live(event type,

event data, handler)

 

$("#Label1").live("mouseover", function () {

alert('live event handler method');

});

The live handler method attaches a handler to a jQuery event for the elements  matching the selector to the "eventType" string containing a event type, such as "click" or "mouseover." With jQuery 1.4 the event string can contain multiple, space-separated event types or custom programmer events. The "eventData" string is data that will be passed to the event handler. The "handler" string is a function to run when the event is triggered. 
 die

 $(selector).die()

OR 

$(selector).die(event type, handler)

  

 

Unbind all event handlers attached using "live" from the page

elements. eventTypeA string containing a JavaScript event type, such as click or keydown. handlerThe function that is to be no longer executed.