RadNotification can be configured to perform a WCF Service AJAX call to update its content, which in general leads to an improved performance. In order to enable this, you should set the WcfRequestMethod, WcfMethodPath and the WcfMethodName properties of the control.
<
telerik:RadNotification
ID
=
"RadNotification1"
runat
=
"server"
LoadContentOn
=
"EveryShow"
WcfRequestMethod
=
"POST"
WcfServicePath
=
"XmlHttpPanelWcfService.svc"
WcfServiceMethod
=
"GetCustomerByID"
OnClientUpdating
=
"OnClientUpdating"
>
</
telerik:RadNotification
>
There are three client events where you can handle the items request:
- The OnClientUpdating event occurs just before the notification content is updated. This event is cancellable. It will not be fired when the content is static. It is only fired when new content is received via a WebService or via a callback. The LoadContentOn setting is also used to control whether it will be fired or not.
- The OnClientUpdated event occurs just after the notification content is updated. This event is not cancellable. It will not be fired when the content is static. It is only fired when new content is received via a WebService or via a callback. The LoadContentOn setting is also used to control whether it will be fired or not.
- The OnClientUpdateError event occurs if there has been an error when the RadNotification content should be updated. An error alert which can be canceled is displayed.
Setting the Value property of RadNotification depends on the WcfRequestMethod property value. In both cases CustomerID is the name of the parameter in the Wcf Service method.
- "POST" - '{"CustomerID":"value"}'
- "GET" - 'CustomerID=value'
The WCF Service should have the following implementation:
- Define the contracts of the WCF Service in an interface. The Method = "POST"/"GET" corresponds to the value of the WcfRequestMethod property.
[ServiceContract]
public
interface
IXmlHttpPanelWcfService
{
[OperationContract]
[WebInvoke(Method =
"POST"
, BodyStyle = WebMessageBodyStyle.Wrapped,
ResponseFormat = WebMessageFormat.Json)]
string
GetCustomerByID(
string
CustomerID);
}
- Define the WCF Service class
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public
class
XmlHttpPanelWcfService : IXmlHttpPanelWcfService
{
public
string
GetCustomerByID(
string
CustomerID)
{
return
"The content of the notification"
;
}
}
- Define the configuration in the web.config file
<
system.serviceModel
>
<
behaviors
>
<
endpointBehaviors
>
<
behavior
name
=
"XmlHttpPanelWcfBehavior"
>
<
webHttp
/>
<
behavior
>
<
endpointBehaviors
>
<
serviceBehaviors
>
<
behavior
name
=
"XmlHttpPanelWcfBehavior"
>
<
serviceMetadata
httpGetEnabled
=
"true"
/>
<
serviceDebug
includeExceptionDetailInFaults
=
"true"
/>
<
behavior
>
<
serviceBehaviors
>
<
behaviors
>
<
services
>
<
service
behaviorConfiguration
=
"XmlHttpPanelWcfBehavior"
name
=
"XmlHttpPanelWcfService"
>
<
endpoint
address
=
""
binding
=
"webHttpBinding"
contract
=
"IXmlHttpPanelWcfService"
behaviorConfiguration
=
"XmlHttpPanelWcfBehavior"
/>
<
service
>
<
services
>
<
system.serviceModel
>
Click on a person to see whether he/she is available for an online conversation.