Showing posts with label greetings. Show all posts
Showing posts with label greetings. Show all posts

Monday, March 26, 2012

CallBack issues with AjaxControlToolKit

Greetings.

We recently encountered a problem while using the AjaxControlToolkit library. We have designed a "one-page" project, whereas none of the controls is present in the markup code at startup. At some point after the page has already been rendered we make a AJAX Call to our WebService which is responsible for programmatically creating controls, put them into a server-side page, renders the content, splits markup, javascript and reference scripts, and finally sends this three split up parts to the client through the callback.

This scenario works fine as long, as we stick to the standard webui controls or even the ComponentArt controls. But when we were trying to implement a AjaxControlToolkit control, the whole thing failed. The procedure was nearly the same when adding a normal webui control, only that we had to programmatically add a ToolkitScriptManager to our server-side created page where we throw in all the controls. We added a ToolKit control, rendered the page, split it up as usual and sent the results to the client.

The rendered markup still looked good, and the referenced scriptfiles which the client had to reinclude seemed ok, too. But the javascript rendered throws an error, which we can't tail. On one machine it throws an "AjaxControlToolkit is undefined"- javascript error, on another it throws a syntax error which is very vague.

So has anyone tried to programmatically implement the AjaxControlToolkit recently and any clues to what we seem to have missed? Help is really appreciated since we have some kind of deadline, and really wish to implement the cool features of the toolkit :)

Best regards and thanks in advance.

Hi,

Based on your description, I have a general idea of what are you trying to implement. Though, in my opinion, it's cool but may be not that efficient.

Can you create a small sample to illustrate the issue more intuitively, so that I can use it directly and try to find out the cause.

Call javascript function after UpdatePanel

Greetings, I have an UpdatePanel that gets triggered by a ControlEventTrigger button
click event. My question is this:
After the Update (request) is complete, I need to run a javascript function to do some work.
Is there a sort of "OnRequestComplete" property that I can use to specify the names of the JS functions that i want to run?


Thanks.

There isn't anything like OnRequestComplete that you can use. However, this is possible. In whatever server-side code that is executed.

ClientScript.RegisterStartupScript(Me.GetType(),"alert('Update done.');",true)

rchern13, the example you gave me above works fine.
ClientScript.RegisterStartupScript(Me.GetType(), "KeyName", "alert('Update done.');" ,true)

but if I put the alert inside a function, the function doesn't run.
ClientScript.RegisterStartupScript(Me.GetType(), "KeyName", "function update() {alert('Update done.');}" ,true)

Any thoughts? Thanks.


Where do you call the update function?

Hey guys please note ..

If you want the script to be registered at runtime you must make sure that the page does postback andthis should not be an atlas post back because in such case the script will not register or fire the required command

It should be done in PageLoad Event of the Asp.Net Page

or if you are not using Atlas in you application to display messages you can use the following code

Sub AlertMessage(ByVal StrMessage As String)
Dim strScript As String = "<script language=JavaScript>"
strScript += "alert(""" & StrMessage & """);"
strScript += "</script>"

If (Not Page.ClientScript.IsStartupScriptRegistered("Alertscript")) Then

'For asp.Net 1.0 and +
'Page.ClientScript.RegisterStartupScript("clientScript", strScript)

'For asp.Net 2.0
Page.ClientScript.RegisterStartupScript(Me.GetType, "Alertscript", strScript)
End If
End Sub


Asifsolkar, I disagree with you. I have a page with a structure like the following:

Page
--Update Panel
--Details View
--Command Button

The command button event handler includes the following line:

ClientScript.RegisterStartupScript(

Me.GetType,"approve","alert('" & str &"'); ",True)

The final effect of this is that my page inserts the record (the DV is in insert mode by default) into the database and I see the alert without a full postback.


I agree with rchern13. I was registering the function, but not calling it. Once I made a call to my JS functions, things are running as intended.
Rchern13, This forum is lucky to have an expert like you! Your time and help are appreciated.

Thanks.


Big Smile

I'm no expert, just somehow who drove everyone crazy while I was learning Atlas and am now trying to do my part to help the community.


Hi, I need to do that same - but couldnt get it to work withv2.0.50727.60626, does this work with this version? Or is thisthere any alternative?

Thanks
Jim
Yes, it will work. What error are you getting?
Thanks for replying, I wasn't actually getting any error, it's just wasn't firing the alert.

However, I just tried removing the other custom controls from my form(which emit their own JS) and it works... so I guess theres someconflict there.

Thanks
Jim