Monday, March 26, 2012

Cause Postback with a Clientside Javascript

Hello,

I'm attempting to, with use of Clientside Javascripts (called from a Flash movie), to cause a Postback that will allow me to update the content of a GridView on my ASP.NET AJAX Page.

I've spend a lot of time looking at the documentation for the clientside framework, but I haven't been lucky enough to find anything. I realize that this poses the problem of a control having to cause a postback - but is there some way to do this (some workarround)?

Regards,
Jonas

Hi Jonas,

The way I do it (and I'm not sure it's a best practice / it is certainly a workaround ;) ) is the following:

To cause a postback: let the javascript find a button on the page (a server-side button) (for example: document.getElementById('MyButton')

Then you can touch the click event of that button

Make that click event cause a full postback or a partial postback (callback) if the button is a trigger of an updatepanel.

I hope all makes sence.
If you have further questions/remarks I'd like to hear them.

Greetz
Wim


HI Jonas,

You can write a javascript function withdocument.aspnetForm.submit(); statement in it and call it from your Flash. This will cause a postback and you can update the content.



A call to Sys.WebForms.PageRequestManager.getInstance()._doPostBack() is a good way to do it.

No comments:

Post a Comment