Welcome Guest Search | Active Topics | Sign In | Register

CallbackPanel RenderScriptBlock Options
Jack Brown
Posted: Wednesday, March 10, 2010 3:42:23 PM
Rank: Newbie
Groups: Member

Joined: 3/10/2010
Posts: 2
I am using the CallbackPanel as part of a server control. I have a TreeView control inside the CBP. The TV control scrolls. When I select a node in the TV, I want to be able to view that node (scrollIntoView). I understand that I need to use javascript to do this. In an UpdatePanel, I think I would use ScriptManager.RegisterStartupScript to register the script. I thought the CallbackPanel.RenderScriptBlock would be a comparable method, but it doesn't work as expected. I used the method to register a simple alert script and it doesn't show up after postbacks. Also, I don't see the script in the source.

Is there another method I can use to cause jscript to run on startup after a postback using the CBP?
eo_support
Posted: Wednesday, March 10, 2010 3:54:25 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Check whether you have enclosed your code inside "<script>" tag. For example the following code is wrong:

Code: C#
CallbackPanel1.RenderScriptBlock("test", "alert('hi')");


The correct form should be:

Code: C#
CallbackPanel1.RenderScriptBlock("test", "&lt;script&gt;alert('hi')&lt;/script&gt;");


You will not see your script in page source because the source is always the source when the page was initially loaded, not after the callback.

Thanks!
Jack Brown
Posted: Wednesday, March 10, 2010 4:21:48 PM
Rank: Newbie
Groups: Member

Joined: 3/10/2010
Posts: 2
Jumped the gun, was expecting the script to show up on startup - understand now that it won't show up until the CBP is used... don't happen to have any samples of what I need to do (make a treeview node visible after the postback/callback)... thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.