troubleshooting Question

open.window from codebehind

Avatar of md0333
md0333Flag for United States of America asked on
ASP.NETVisual Basic.NETWeb Development
18 Comments1 Solution4911 ViewsLast Modified:
I've seen several solutions to doing this but I have yet to get one to work...

I have a website that I'm trying to get (from login) to open a web application in a new window. Once the user logs in and gets validated I set some session variables and then choose the page the user goes to based on their security level. If I use the response.redirect() then it works fine... just doesn't open in a new window but my point is that I know the user is being validated. But if I try to call the javascript (or build the javascript) from codebehind it immediately takes the app to the logout screen.

Here is the last piece of code I tried
        Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
        sb.Append("<script language='javascript'>")
        sb.Append("window.open('webapp.aspx', '', 'resizable=yes, menubar=no, toolbar=no,   status=no, location=no, channelmode=yes')<")
        sb.Append("/script>")

        If Not ClientScript.IsClientScriptBlockRegistered(Me.GetType(), "PopupScript") Then
            ClientScript.RegisterClientScriptBlock(Me.GetType(), "openPopUp", sb.ToString())
            'ClientScript.RegisterStartupScript(Me.GetType(), "openPopUp", sb.ToString())
            'Response.Write(sb.ToString())
        End If

Open in new window



you can see I have tried a couple different methods... I've tried several others also including this one.
codebehind
Dim url As String = "~/webapp.aspx"
        ClientScript.RegisterStartupScript(Me.GetType(), "openwin", "<script>openPopUp2('" & url & "')</script>")

aspx
function openPopUp2(url) {
            alert('hi');
            window.open(url, "", " resizable=yes, menubar=no, toolbar=no, status=no, location=no, channelmode=yes");
        }

Open in new window


I put the alert in there just to see if it was even hitting the javascript code and it is not... not sure what to try next.

thanks
ASKER CERTIFIED SOLUTION
Carlos Villegas
Full Stack .NET Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 18 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 18 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros