Dear Telerik,
Been making a few experiments with the famous PortalSiteCS demo in order to try to understand some problems I am having with the app I am developing.
I made two simple modifications:
1) added the following script to news.ascx
<script>
function theFunction()
{
alert('Hey, someone has called theFunction!!!');
}
</script>
2) added one button to the end of the form in default.aspx
<input type="button" onclick="theFunction();" />
The problem is that the button cannot actually call theFunction when you start clean and just add one 'news widget' - but no script error is caught at the browser.
But the story gets completely different after a postback (a page reload or whatever). After an 'F5' the button is actually able to call theFunction.
This seems related to the problems I'm getting in my app. So... my question is: how can I ensure that the user control scripts get loaded right when the widget is created for the 'first time'? - in this case via the add dock button.
Hope my description is clear enough. Thanks,
Paulo
6 Answers, 1 is accepted
I am attaching our PortalSiteCS demo modified to include the changes in the News widget. My tests show that the script gets executed the first time as well. Please, test with it and in case you still experience problems, contact us again.
Greetings,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thanks for your reply.
Well.. I guess I didn't explain the scenario properly. It all has to do with the concept of 'first time'. Here goes the sequence:
1) start the application
2) close all the active widgets
3) when no more widgets are in the docks press CTRL+F5
4) add one news widget to the page
5) press 'the button'.
*** The problem should happen here ***
But if you press CTRL+F5 between 4) and 5) then the button will be able to call theFunction
Please try it.
Thanks,
Paulo
Thank you for this clarification. You need to register your script via the ScriptManager as the controls are added on AJAX callback. For example you can add this code to the Page_Load of News.ascx:
ScriptManager.RegisterStartupScript(this, this.GetType(), "Script", "function theFunction(){alert('Hey, someone has called theFunction!!!');}", true);
Hope this helps.
Sincerely yours,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Seems RegisterStartupScript() in Page_Load() doesn't work when a dock is being added dynamically. It makes sense only when whole page refreshes or loads first time. The cause may be the fact that Page_Load() is called only the page is being loaded, but it doesn't take place when a dock is being added dynamically.
Unfortunately I don't see how to attach a file to my post :(
How is it possible?
I have the similar scenario in real project. I'm about to move the startup script to RadDock.OnClientInitialize event handler to make it work. After trying this I'll let you know the results.
Thanks,
Roman
I've just finished testing OnClientInitialized. It works as opposed to RegisterStartupScript.
Also have another question.
Guys, is anywhere normal manual on client-side API?
Javascript resources (files) are obfuscated, so it's not possible to use them as a reference. That manual you propose for downloading ("RadControls_Prometheus_Manual_2007.3.1218.chm") is very small :(
E.g. it doesn't describe Initialize client event at all - i even don't know how to implement the handler without searching the forum.
I'll be grateful for your assistance.
Thanks,
Roman
Attaching files to your thread is possible if you open a support ticket. See the attached instructions for reference. If you still experience any problems we encourage you to send us a simple working project reproducing them along with instructions on how we can observe the issues. Regarding the client-side API - we are working on significantly improving the documentation but for now all you can use is the mentioned manual and the following online demos:
Client-side events
Client-side API
Should you encounter any problems do not hesitate to contact us and we will guide you how to solve the problem.
Greetings,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center