tags:

views:

159

answers:

2

Hello! I have an interesting problem when using partial page update in asp.net with scriptmanager and a update panel.

My scenario looks like this: I'm using the tab control from the ajax toolkit. I also implemented this control using lazy loading, so that when the page is loaded only the current tab gets loaded all the other tabs don't get rendered, because Im using an UpdatePanel (on a .ascx control) on each of these tabs and when a tab gets selected the updatepanel makes a async postback to load the content for a selected tab.

On one of my tabs Im using a combobox control from obout.com, and it doesn't work. Now I know why it doesn't work. It doesn't work because the control is shown via a partial page refresh, but to correctly display the control it has to do some "magic" that is - register some .css and .js includes on the page (in the head I guess)....but because I load this control via async page refresh...it can't do these stuff.

What kind of workarround do you suggest? Thanks!

A: 

Assuming you have done partial ajax updates in asp.net before, then you simply need to register a client block with the ScriptManager for when the partial update is triggered.

Without knowing your problem space, it's difficult to paste specific code for you, so instead I'll just suggest you read this and then ask more questions if you have them...

http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerclientscriptblock.aspx

BTW, if you're dynamically creating the controls as well as partially updating them, then you will also need to be very careful of your viewstate. This is a can of worms, so hopefully you are not and won't have to worry about it.

BenB
hmmm ok...but I don't know what to register or how to register...all I know is that the control doesn't work because this client block is missing : var tempStyleSheet= document.createElement('link');tempStyleSheet.rel='stylesheet'; tempStyleSheet.type='text/css';tempStyleSheet.href="/WebResource.axd?d=WN8o_1mSR3c5ZcycIrIgY5X-rne-Lk2UnnW9O4PYJHhL e1cEIZ9xqlugWWi_RGrXl48ODBlfTSGKV_ONmlt3Ps7iyLa9n9SaSfKxBXza8MI1 document.getElementsByTagName('head')[0].appendChild(tempStyleSheet);Do I just copy this into the string parameter?
Jernej Gorički
Ok, I Registered this resource and the control got its looks...but not the functionality, probably i also need to include a .js file, but I don't know where to find this file?
Jernej Gorički
Have you managed to get this special control working without an update panels and the ajax controls?
BenB
yes...works fine without an update panel...I already send an example to their development team so we will see :)
Jernej Gorički
Jernej Gorički
A: 

As I suspected you have to manually register the needed scripts for ajax controls to work in such a manner. For example here is the solution for telerik controls: http://www.telerik.com/help/aspnet-ajax/troubleshooting.html

Here is a solution using devexpress controls: protected void Page_Load(object sender, EventArgs e) { DevExpress.Web.ASPxClasses.ASPxWebControl.RegisterBaseScript(this); }

I didn't found a solution for obout.com controls.

Jernej Gorički