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?
|
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", "<script>alert('hi')</script>");
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!
|
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
|