I followed the below tutorial link to populate a RadComboBox using WCF service.
This works fine on localhost but when I deploy it on the server I'm getting an error "The server method 'LoadClients' failed" whenever this service is called.
http://www.telerik.com/help/aspnet-ajax/combobox-load-on-demand-wcf-service.html
WebConfig:
WCFClients.svc:
aspx:
Thank you for your help!!
This works fine on localhost but when I deploy it on the server I'm getting an error "The server method 'LoadClients' failed" whenever this service is called.
http://www.telerik.com/hel
WebConfig:
<
system.serviceModel
>
<
behaviors
>
<
endpointBehaviors
>
<
behavior
name
=
"WCFClientsAspNetAjaxBehavior"
>
<
enableWebScript
/>
</
behavior
>
</
endpointBehaviors
>
</
behaviors
>
<
serviceHostingEnvironment
aspNetCompatibilityEnabled
=
"true"
/>
<
services
>
<
service
name
=
"WCFClients"
>
<
endpoint
address
=
""
behaviorConfiguration
=
"WCFClientsAspNetAjaxBehavior"
binding
=
"webHttpBinding"
contract
=
"WCFClients"
/>
</
service
>
</
services
>
<
bindings
>
<
webHttpBinding
>
<
binding
name
=
"webBinding"
>
<
security
mode
=
"Transport"
>
</
security
>
</
binding
>
</
webHttpBinding
>
WCFClients.svc:
<OperationContract()> _
Public
Function
LoadClients(
ByVal
context
As
RadComboBoxContext)
As
RadComboBoxData
'The RadComboBoxData object contains all required information for load on demand:
' - the items
' - are there more items in case of paging
' - status message to be displayed (which is optional)
Dim
result
As
New
RadComboBoxData()
' Dim connectionStr As String = Current.Session("ConnectionString").ToString
Dim
connectionStr
As
String
=
"MyConnectionString"
Dim
TransMgr
As
New
TransmgrClientsDataContext(connectionStr)
'Get all items from the Customers table. This query will not be executed untill the ToArray method is called.
Dim
allCustomers = From c
In
TransMgr.Clients _
Order By c.LastNm _
Select
customer =
New
RadComboBoxItemData
With
_
{.Text = c.LastNm &
" "
& c.FirstNm, .Value = Convert.ToString(c.Clnt_No)}
'In case the user typed something - filter the result set
If
Not
[
String
].IsNullOrEmpty(context.Text)
Then
allCustomers = allCustomers.Where(
Function
(item) item.Text.StartsWith(context.Text))
End
If
'Perform the paging
' - first skip the amount of items already populated
' - take the next 10 items
Dim
customers = allCustomers.Skip(context.NumberOfItems).Take(10)
'This will execute the database query and return the data as an array of RadComboBoxItemData objects
result.Items = customers.ToArray()
Dim
endOffset
As
Integer
= context.NumberOfItems + customers.Count()
Dim
totalCount
As
Integer
= allCustomers.Count()
'Check if all items are populated (this is the last page)
If
endOffset = totalCount
Then
result.EndOfItems =
True
End
If
'Initialize the status message
result.Message = [
String
].Format(
"Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>"
, endOffset, totalCount)
Return
result
End
Function
aspx:
<
script
type
=
"text/javascript"
>
function validateCombo(source, args) {
args.IsValid = false;
var combo = $find(source.controltovalidate);
var selectedItem = combo.get_selectedItem();
if (selectedItem) {
var value = selectedItem.get_value();
if (value > 0) {
args.IsValid = true;
}
}
}
</
script
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"rcbClients"
Height
=
"100px"
EnableLoadOnDemand
=
"true"
ShowMoreResultsBox
=
"true"
EnableVirtualScrolling
=
"true"
AllowCustomText
=
"false"
EmptyMessage
=
"Type lastname ..."
>
<
WebServiceSettings
Path
=
"WCFClients.svc"
Method
=
"LoadClients"
/>
</
telerik:RadComboBox
>
<
asp:CustomValidator
ID
=
"cvClients"
runat
=
"server"
ClientValidationFunction
=
"validateCombo"
SetFocusOnError
=
"true"
ErrorMessage
=
"Please select a client from Dropdown"
ControlToValidate
=
"rcbClients"
>*
</
asp:CustomValidator
>
Thank you for your help!!