• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1086
  • Last Modified:

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.
0
Starr Duskk
Asked:
Starr Duskk
  • 3
  • 2
  • 2
2 Solutions
 
GiftsonDJohnCommented:
Hi,

In Asp.Net Ajax Page.ClientScript.RegisterClientScriptBlock will not work as expected during Asynchronous postback.

try replacing Page.ClientScript.RegisterClientScriptBlock with ScriptManager.RegisterClientScriptBlock
0
 
jmwheelerCommented:
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.
0
 
jmwheelerCommented:
Sorry wrong question.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
It says ScriptManager is not declared.
>>ScriptManager.RegisterClientScriptBlock...
 
I have a reference and imports:

Imports System.Web.UI
 
0
 
GiftsonDJohnCommented:
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.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
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.
 
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I didn't get an answer that worked on this, but I rigged it to check which panel is  loading, and if the first, I register the script with the first panel, if the second, I register it with the second panel, that way I don't register it twice, but it gets registered either way.
thanks!
 
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now