Hi,
I'm having issues with RadLive capturing the value returned by my web service. I believe the web service is returning an xml while RadLiveTile is expecting a jason format. Can you please help me here?
WebService business logic:
[DataContract] public class GarageMap { [DataMember] public int OccupiedSpaces{set;get;} public GarageMap() { } public GarageMap(int propertyid) { loadMap(propertyid); } private void loadMap(int property_id) { DBTransaction Transaction = new DBTransaction(); DBTransactionParameter param = new DBTransactionParameter(); param.Type = SqlDbType.VarChar; param.Name = "@PropertyID"; param.Value = "3"; List<DBTransactionParameter> plist = new List<DBTransactionParameter>(); plist.Add(param); DataTable DT = Transaction.Select("sp_GetAllOccupiedSpacesCount", true, plist); DataRow dr = DT.Rows[0]; OccupiedSpaces= Convert.ToInt32( dr["AllOccupiedSpaceCount"].ToString()); } }WebMethod:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet=false)]
//[ScriptMethod(UseHttpGet = true)]
public GarageMap OccupiedSpaceCount()
{
//string j = "{'test': 1}";
////return j;
return new GarageMap(3);
}
ASPX Page:
<div class="tilesWrapper"> <telerik:RadLiveTile ID="DellTile" NavigateUrl="http://finance.yahoo.com/q?s=FB&d=t" runat="server" UpdateInterval="3000" Value="FB"> <Title ImageUrl=""></Title> </telerik:RadLiveTile> <telerik:RadLiveTile ID="GoogleTile" NavigateUrl="http://finance.yahoo.com/q?s=GOOG&d=t" runat="server" UpdateInterval="4000" Value="GOOG"> <Title ImageUrl="../../images/LiveTiles/logo_Google.png"></Title> </telerik:RadLiveTile> <telerik:RadLiveTile ID="YahooTile" NavigateUrl="http://finance.yahoo.com/q?s=YHOO&d=t" runat="server" UpdateInterval="5000" Value="YHOO"> <Title ImageUrl="../../images/LiveTiles/logo_Yahoo.png"></Title> </telerik:RadLiveTile> <telerik:RadLiveTile ID="MicrosoftTile" NavigateUrl="http://finance.yahoo.com/q?s=MSFT&d=t" runat="server" UpdateInterval="6000" Value="MSFT"> <Title ImageUrl="../../images/LiveTiles/logo_Microsoft.png"></Title> </telerik:RadLiveTile> </div> Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
InitializeTile(DellTile);
//InitializeTile(GoogleTile);
//InitializeTile(YahooTile);
//InitializeTile(MicrosoftTile);
}
private void InitializeTile(RadLiveTile tile)
{
tile.CssClass = "liveTile";
tile.Target = "_blank";
//The text between the #= # characters is replaced by the corresponding properties of the data item
//returned on the web service response.
tile.ClientTemplate = @"
<div class=""tileClientTemplate"">
<div><strong>change:</strong> <img src=""../Assets/Icons/arrow_down.png"" alt="""" /> #= OccupiedSpaces #</div>
<div><strong>stock quote:</strong> #= OccupiedSpaces #</div>
<div><strong>updated:</strong> #= OccupiedSpaces #</div>
</div>
";
//Configure the web service providing the live data.
tile.WebServiceSettings.Path = "http://ws.smartparkllc.com/Dashboard.asmx";
tile.WebServiceSettings.Method = "OccupiedSpaceCount";
//Attach client side event handlers.
tile.OnClientDataLoaded = "tileDataLoaded";
tile.OnClientDataLoadingError = "tileDataLoadingError";
tile.OnClientTemplateDataBound = "tileClientTemplateDataBound";
}
Java Script File:
<script type="text/javascript">
//alert("boom");
function tileDataLoadingError (sender, args) {
args.set_cancelErrorAlert(true);
}
//The dataLoaded client side event occurs after the data request returns the data successfully.
function tileDataLoaded(sender, args) {
//
var data = args.get_data();
//format the received date property
//data.LastUpdated = data.LastUpdated.format("yyyy.MM.dd HH:mm:ss");
}
//The templateDataBound client-side event occurs after the client template is data bound.
function tileClientTemplateDataBound(sender, args) {
alert("boom");
if (args.get_dataItem().Change >= 0) {
args.set_html(args.get_html().replace("Assets/Icons/arrow_down.png", "Assets/Icons/arrow_up.png"));
}
}
</script>
Browser Webservice call output:
<?xml version="1.0" encoding="utf-8"?>
<GarageMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<OccupiedSpaces>3</OccupiedSpaces>
</GarageMap>
Browser Console Error:
Uncaught SyntaxError: Unexpected token <