-
Book Overview & Buying
-
Table Of Contents
Ext.NET Web Application Development
By :
As we have seen, DirectEvents are very powerful; they are attached to an Ext.NET control and called when that event fires and invokes a server method. As powerful as they are, you may want to call a server method at your own choosing, directly from within your own JavaScript function—similar to invoking ASP.NET's own page methods. As we noted earlier, DirectEvents require the control to be recreated on the server as part of the page lifecycle. A DirectMethod, however, doesn't require a control instance on the server (unless it is defined inside a user control). Furthermore, if you use a static DirectMethod, it won't even require the full page lifecycle. Otherwise, most things possible with DirectEvents are possible with DirectMethods. Here are a few examples.
On the server side, a DirectMethod looks very similar to an ASP.NET page method. Consider the following example:
[DirectMethod]
public void AddToServerTime(int hours)
{
var date = DateTime.Now.Add...
Change the font size
Change margin width
Change background colour