Need Help with Silverlight (Book Widget) in RC2
Hello,
I am having trouble getting the Book Widget to work in the web app sample that came with the RC2 download. I am new to Sitefinity and slowly finding my way, but have gotten stuck here. When I navigate to the Book Widget an error is thrown on this line of code:
slCtl.Content.mainPage.SetBookProperties(Sys.Serialization.JavaScriptSerializer.deserialize(
this
.get_properties().toJSON()));
Hello Steven,
Thank you for contacting Telerik Support.
The has been a bug with this control which has been fixed now. Can you please go to the BookWidget project -> Resources -> Book.js file and edit the bellow function:
was:
pluginLoaded:
function
(sender, args)
var
imagesArr = Sys.Serialization.JavaScriptSerializer.deserialize(
this
.get_imagesCollection());
slCtl = sender.getHost();
for
(idx
in
imagesArr)
slCtl.Content.mainPage.SetItem(imagesArr[idx][
'Url'
]);
slCtl.Content.mainPage.SetBookProperties(Sys.Serialization.JavaScriptSerializer.deserialize(
this
.get_properties().toJSON()));
pluginLoaded:
function
(sender, args)
var
imagesArr = Sys.Serialization.JavaScriptSerializer.deserialize(
this
.get_imagesCollection());
slCtl = sender.getHost();
for
(
var
idx = 0; idx<imagesArr.length; idx++)
slCtl.Content.mainPage.SetItem(imagesArr[idx][
'Url'
]);
slCtl.Content.mainPage.SetBookProperties(Sys.Serialization.JavaScriptSerializer.deserialize(
this
.get_properties().toJSON()));
Thanks very much for the reply. I tried the recommended edit in the Book.js file, but it did not work for me. I rebuilt the entire solution, cleared the browser cace and then repeated this after 'cleaning' the solution, but the same error showed up. Do you have any further suggestions?
Thanks.
Hello Steven,
Please try inspecting the script files loaded by the page. Check if the old scripts are loaded or the new ones. I am not able to reproduce the error with proposed changes.
Best wishes,
Radoslav Georgiev
the Telerik team
Hi,
As best as I can tell, the modified file is loaded. Here is a snippet of what I believe is the relevant code:
// ------------------------------------------------------------------------
// public functions
// ------------------------------------------------------------------------
pluginLoaded:
function
(sender, args)
var
imagesArr = Sys.Serialization.JavaScriptSerializer.deserialize(
this
.get_imagesCollection());
slCtl = sender.getHost();
//for (idx in imagesArr)
//slCtl.Content.mainPage.SetItem(imagesArr[idx]['Url']);
//
for
(
var
idx = 0; idx < imagesArr.length; idx++)
slCtl.Content.mainPage.SetItem(imagesArr[idx][
'Url'
]);
slCtl.Content.mainPage.SetBookProperties(Sys.Serialization.JavaScriptSerializer.deserialize(
this
.get_properties().toJSON()));
,
Hello Steven,
Can you please put a breakpoint in the last line of this JavaScript method and see if any of the locals will return undefined?
Regards,
Radoslav Georgiev
the Telerik team
OK, I did that. 'args' returns undefined.
Hello Steven,
The args is not used in the method so it should not be relevant. Can you see if slCtl.Content.mainPage.SetBookProperties
is undefined or if any of the parameters passed is?
Regards,
Radoslav Georgiev
the Telerik team
Thanks for your continued attention to the problem I am facing. Although I have significant programming experience, I have just recently entered the .NET and Visual Studio world. I have the assignment of evaluating Sitefinity for our agency and seemed to have jumped into the deep end. That's OK, I say it only by way of explaining my answer to your question.
As best as I can tell, there are no undefined variables in the 'locals' window . I can set slCtl as a 'watch' and drill through it. Also as best as I can tell, there are no undefined parameters.
However, I am wondering if my lack of experience with the debugger is keeping me from seeing the obvious. If you can tell me specifically how to get the information you need, I will be happy to do that.
Hi Steven,
Is it possible that you have changed any of the properties of the book widget on the page? For example provided a property value which is not supported?
Best wishes,
Radoslav Georgiev
the Telerik team
I certainly did not change anything deliberately, merely loaded the web app into VS and tried to run it. If I changed something by accident that might be rather difficult to pin down.
Is there a way I can download the web app and start fresh without reinstalling Sitefinity itself?
Hi Steven,
You can download only the Project Manager which you can use to create new projects. However this will not provide you with the the new source code of the samples. You can try this with the new release from today, where the initial issue is fixed.
Best wishes,
Radoslav Georgiev
the Telerik team
Hi,
please take a look at this line:
this.get_properties().toJSON
()
when viewing this.get_properties() in the watch window, there is no toJSON() function.
Hello Steven,
The toJSON() method is coming from the framework. You can find it documented here. This method converts the passed object to JSON format so that it can be communicated to the Silverlight control. You can see the attached image for its return when executed in the console.
Greetings,
Radoslav Georgiev
the Telerik team