Sending script After Async PostBackPostBack

I am sure many of you have been in a situation where you have a form view or details view control inside of an UpdatePanel and after inserting a successful record into the database you went to send a small JavaScript to the end user saying that your record got successfully inserted into the database. I made use of ItemInserted event of FormsView control and used the Page.ClientScript.RegisterStartupScript to inject the JavaScript into the output stream. Unfortunately this ClientScript on the page object does not work when you are inside of an UpdatePanel. Here is the markup and codebehind of my page.

image

The code behind is as follows

image

The markup is the usual stuff that we do in .net 2.0 so I wont be covering that. In the code behind I am making use of Page.ClientScript.RegisterStartupScript to register my script. However this does not work. Instead you have to make use of the method exposed by ScriptManager to send the JavaScript to the browser. Here is how the new code looks like.

image

No Comments