Objectives
This tutorial demonstrates how to use Action context menu in WebNotification. Action context menu provides a way for end users to access a list of available actions and perform an action against notification event.
- Drag WebNotification control from ToolBox into the WebForm.
- Create a WebService page in the same directory and name it "NotificationService.asmx". It will automatically create "NotificationService.cs" in the
App_code folder. WebNotification control will look for GetNotifications method in the WebService. Use the following code for GetNotifications
method:
C#
Copy Code[WebMethod] 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; }
- Open WebNotification Designer and set the following properties of WebNotification control:
Properties Values ServiceType WebService ServiceUrl NotificationService.asmx ShowActionDropdown True
- Add some menu items in Items property and specify a function name for OnClick event.
- Add client side script for OnClick event:
JavaScript
Copy Codefunction doClick(mi) { alert("Clicked : " + mi.Name); }
- Run the page. Menu items will be displayed when Action context menu is clicked.
When the menu item is clicked, an alert box will be displayed.