0

HttpContext.Current.Response.Flush();

ScriptManager.RegisterStartupScript(this, typeof(Page), "Verify", "alert('No Documents Found');", true);

/* By this way I cant call Javascript Function. Please be needful */

Community
  • 1
  • 1
  • 1
    You cannot call JavaScript functions from code behind. Code behind is executed on the server, then the page is rendered and sent to the client, where the result is displayed. Code behind and the client do not interact. – Alexander Apr 21 '16 at 08:59
  • Thanks Alexander for response me. Is there any another way to call JavaScript function after Respose.Flush() ? – Nikunj Patel Apr 21 '16 at 09:08
  • You should add your JavaScript to the HTML output so it is executed after the page has completed loading on the client. Look here for details: http://stackoverflow.com/questions/4994040/scriptmanager-registerstartupscript-code-not-working-why – Alexander Apr 21 '16 at 09:24
  • /* Still Not Working Alexander */ HttpContext.Current.Response.End(); ScriptManager.RegisterStartupScript(this, GetType(), "YourUniqueScriptKey", "alert('This pops up');", true); – Nikunj Patel Apr 21 '16 at 10:00

1 Answers1

0

Your script is not registered because Response.Flush or Response.End actually END the response life cycle and send the results of that point back to the client browser.

Your RegisterStartupScript has no effect.

Alexander
  • 2,457
  • 1
  • 14
  • 17
  • Is the script actually rendered in the final page? Post an excerpt. Try using a debugging tool to see if you get any JavaScript errors. – Alexander Apr 21 '16 at 15:05