Link to home
Start Free TrialLog in
Avatar of Starr Duskk
Starr DuskkFlag for United States of America

asked on

UpdatePanel and Custom Server Control RegisterClientScriptBlock

I have an ajax UpdatePanel. In it there is a combobox on the right, when I click it, it is to update the panel on the left with one of two controls.

When the page initially loads, it loads the first control. When I click, it loads the second control. The second control contains a custom web server control that loads to javascript functions, using: RegisterClientScriptBlock

The page errors when I click to load the second control because the javascript has never been loaded in the page, although when I step through it, it does hit that code with no errors.

If I load the second control first, it does load the script fine.

It appears that loading the second control with ajax doesn't update the javascript as it should.

What are recommendations for getting this javascript loaded on this page. I have thought of putting the javascript for the control in a separate function and calling it on the main page that contains the two controls, however, that seems like a band-aid.

Is there a way to actually load it when the control is loaded that I am missing? Does ajax not support this?

thanks.
SOLUTION
Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmwheeler
jmwheeler

The example above is good, if you are looking to redirect the user when the session actually times out and not when they take an action after they timeout you can use the Timer control (included in .NET 3.5 available as an add-on for .NET 2.0 - ASP.NET AJAX).

Just set the interval to the session timeout and on the Tick event redirect to a timeout page.
Sorry wrong question.
Avatar of Starr Duskk

ASKER

It says ScriptManager is not declared.
>>ScriptManager.RegisterClientScriptBlock...
 
I have a reference and imports:

Imports System.Web.UI
 
Do you have reference for System.Web.Extensions.dll?

If you are able to use UpdatePanel then you should be able to use ScriptManager.  Both are there in the same assembly and namespace.
I've referenced  and done:
Imports System.Web.Extensions
But it errors on the imports line, even though it's in the references.
It says it cannot be found or doesn't contain any public member.
The updatepanel is in my webform in the web site. The stuff I'm trying to register is in a custom server control in a separate project.
 
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial