WebForm-based Notification

This sample demonstrates the basic WebNotification usage with default styles and configurations. In this sample, the WebNotification is using following settings:

- ServiceType: WebForm
- ServiceUrl: WebFormListener.aspx

Summary:

In addition of WebService type, WebNotification also supports notification service using WebForm type. Although both types return exact result, WebForm-based service provides tighter security since the service is not directly exposed to public, and hence is not callable from other pages except from WebNotification control itself. The WebForm service engine is built on the top of FlyPostBack(tm) architecture.

WebNotification control will call the specified ServiceUrl periodically on every 5 seconds (the default value of Interval property). In this sample, the WebNotification will use WebService engine as its ServiceType is set to WebService (default).

The WebNotification control will look for "GetNotifications" method in the specified webform page. The codes look like in the following:

[WebFlyPostBackMethod()]
public WebNotificationEventCollection GetNotifications(WebNotificationEventArgs e)
{
         WebNotificationEventCollection collection = new WebNotificationEventCollection();
         WebNotificationEvent evnt = new WebNotificationEvent();
       
         evnt.CaptionText = "Samples";
         evnt.ContentText = "Hello world from WebNotification!\nCurrent time is:" + DateTime.Now.ToLongTimeString();

         collection.Notifications = new WebNotificationEvent[] { evnt };
         return collection;
}

Note that instead of using "WebMethod" attribute as in WebService type, you should mark the callable function with a special "WebFlyPostBackMethod" attribute. This attribute is provided to distinguish the methods for WebService and WebForm type.

In addition, you also need to include the code in Page_Load which construct the listener. You don't need to do anything on the listener, just the construct code as in following. The Listener is an independent lightweight callback implementation to avoid HttpModule utilization, and is also built on the same architecture as Intersoft's FlyPostBack architecture.

           listener = new WebFlyPostBackListener(this); 

The simple codes above describe that basically the function should return the "collection of events" which type is WebNotificationEventCollection. In this sample, we only return single event which is passed to the Notifications property of the collection object.

Results:
You should be able to see the WebNotification popup in the right bottom (DisplayPosition property) of the WebDesktopWindow. The WebNotification will popup in every 5 seconds (Interval property) and will be displayed in 5 seconds (DisplayLatency property) before the WebNotification begin to fade out.


r