ASP.Net VB call JavaScript function from Code Behind

Susan picture Susan · Feb 10, 2012 · Viewed 59.3k times · Source

I have a function that is responsible for populating an SSRS report. The user presses a button and I go out and check to see if there is data. If no data, I provide a NO DATA message. If there is data I call the SSRS report which I would like to open in a new window. I thought using a JavaScript function would be the best way to accomplish this. How is this done or what would you recommend? Thanks in advance!

    <script type="text/javascript">
        function openWindow(url) {
            document.forms[0].target = "_blank";
        }
    </script>

Answer

coder picture coder · Feb 11, 2012

Try this:

 System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Script", "openWindow(url);", True)