Delegate in JavaScript

JavaScript Event Delegation is a technique you may have heard of. It’s a different way of using event handlers that offers clear benefits and is becoming more popular amongst web developers. I’ll give a brief overview of event delegation in JavaScript, along with why you should consider it. Note that this tutorial will use the great jQuery library for most examples. Delegation Delegation is a fairly well-known design pattern. In short, it is a way for a method to produce its result simply by calling a method on another object, thus delegating responsibility to that object to provide the functionality … Click here to continue…..

Calling MVC Actions from Javascript

Suppose we have a very simple action method: it takes no parameters and just returns a string:

What if we would like to call this action method from javascript through Ajax and to display the value it returns? We can do it with jQuery:

Not so bad, after all. However, let think, about all implications of the above simple raw approach to the interaction with an action method: Repeating the above code several times in an application is annoying, and error-prone. We have no access to Razor helpers from within js files, so we can’t use @Url.Action, and … Click here to continue…..

Calling Postback from Javascript

There may be some scenario where you may want to explicitly postback to the server using some clientside javascript. It is pretty simple to do this. ASP.NET already creates a client side javascript method as shown below to support Postbacks for the web controls:

So, all you have to do is, just call this method with appropriate arguments. You may call this as shown below:

However, it is not recommended to use this method name directly in the client side. The best approach is, generate this piece of code from the code behind file using ASP.NET. This way, … Click here to continue…..

How to add watermark on a textbox by using javascript?

There are 3 ways to add watermark functionality on a textbox by using javascript.

Or

Or

this function call on body onload event

How to disable back button of browser?

By using java script it can be done

Or

Or