RadXmlHttpPanel 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:RadXmlHttpPanel
ID
=
"RadXmlHttpPanel1"
runat
=
"server"
WcfRequestMethod
=
"POST"
WcfServiceMethod
=
"PostRetrieveProductByID"
WcfServicePath
=
"XmlHttpPanelWcfService.svc"
>
</
telerik:RadXmlHttpPanel
>
There are three client events where you can handle the items request:
- The OnClientResponseEnding event occurs just before the RadXmlHttpPanel content is updated. This event is cancellable.
- The OnClientResponseEnded event occurs just after the RadXmlHttpPanel content is updated. This event is not cancellable.
- The OnClientResponseError event occurs if there has been an error when the RadXmlHttpPanel content should be updated. An error alert which can be canceled is displayed.
Setting the Value property of RadXmlHttpPanel 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
{
//"POST" or "GET" depends on the WcfRequestMethod property value
[OperationContract]
[WebInvoke(Method =
"POST"
, BodyStyle = WebMessageBodyStyle.Wrapped,
ResponseFormat = WebMessageFormat.Json)]
string
PostRetrieveProductByID(
string
ProductID);
}
-
Define the WCF Service class
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public
class
XmlHttpPanelWcfService : IXmlHttpPanelWcfService
{
public
string
PostRetrieveProductByID(
string
ProductID)
{
return
"The content of the XmlHttpPanel"
;
}
}
-
Deifne 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
>