views:

130

answers:

1

I'm using a custom control in ASP.NET that handles file uploading for me. The control has a handler in the code-behind using something like this:

Protected Sub UploadFileComplete(ByVal sender As Object, ByVal e As UploadControl.FileUploadCompleteEventArgs) Handles UploadControl.FileUploadComplete

Within that sub, I post back to the server and do some work on the database, but then when I come back, I want javascript to register at that point.

However, when I use Page.ClientScript.RegisterClientScriptBlock or ScriptManager.RegisterClientScriptBlock, the scripts don't load on the page. I need this javascript to run and update the page, and to close the upload dialog window. I assume it's because the page is already loaded.

Does anyone have any good ideas on how to do this?

Thanks in advance.

A: 

Alright so turns out it's like this...

On the server side (code-behind), in the UploadFileComplete() sub, you can access that EventArgs variable by using the method "e.CallbackData = [WHATEVER]".

And then in your javascript, you use this built in client function:

function UploadComplete(args){ alert(args.callbackData); }

And that args.callbackData variable has whatever you put in via server side. Pretty slick I think! But hard to figure out cause they didn't have it documented very well.

This way, you don't need to add your own RegisterClientScriptBlock method, because you can pass in anything you want to JavaScript using their built in method.

MattK311