Literal control to open browser window

after a user clicks a button on my page, I want it to open a new browser window. I am trying to use a literal control to do it, but it isn't working. It does add the code to the page when you view it in the browser using view/source.

here is my code

 Dim sb As New StringBuilder()
        sb.Append("<script language=""JavaScript"" type=""text/JavaScript"">")
        sb.Append("window.open('testsens.aspx?recid=" & grabCurrent.SelectedValue & "','" & grabCurrent.SelectedItem.Text & "','width=600,height=500,resizable=1');")

        sb.Append("</script>")

        lit1.Text = sb.ToString
NickMalloySystems LeadAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aki4uCommented:
try to cahange  lit1.Text = sb.ToString

with this:

Page.RegisterStartupScript("JSKey",  sb.ToString)
NickMalloySystems LeadAuthor Commented:
Didn't do anything
aki4uCommented:
i tried it and works without problems.

where is your page 'testsens.aspx'?

did you disabled javascript?
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

NickMalloySystems LeadAuthor Commented:
javascript is enabled.

here is my code

Protected Sub btnUpScen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpScen.Click
       
        Dim sb As New StringBuilder()
        sb.Append("<script language=""JavaScript"" type=""text/JavaScript"">")
        sb.Append("window.open('testsens.aspx?recID=" & grabCurrent.SelectedValue & "','" & grabCurrent.SelectedItem.Text & "','width=600,height=500,resizable=1');")

              sb.Append("</script>")

        lit1.Text = sb.ToString

       Page.RegisterStartupScript("JSKey", sb.ToString)
        '  Page.ClientScript.RegisterStartupScript("JSKey", sb.ToString)

    End Sub
aki4uCommented:
are you using framework 1.1 or 2.0?


Protected Sub btnUpScen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpScen.Click  
        Dim sb As New StringBuilder()
        sb.Append("<script language='javascript'>")
        sb.Append("window.open('testsens.aspx?recID=" & grabCurrent.SelectedValue & "','" & grabCurrent.SelectedItem.Text & "','width=600,height=500,resizable=1');")
        sb.Append("</script>")
        Page.RegisterStartupScript("JSKey", sb.ToString())
    End Sub
NickMalloySystems LeadAuthor Commented:
2.0
aki4uCommented:
ok.
try this one:

Protected Sub btnUpScen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpScen.Click  
        Dim sb As New StringBuilder()
        sb.Append("<script language='javascript'>")
        sb.Append("window.open('testsens.aspx?recID=" & grabCurrent.SelectedValue & "','" & grabCurrent.SelectedItem.Text & "','width=600,height=500,resizable=1');")
        sb.Append("</script>")
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "JSKey", sb.ToString())
    End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NickMalloySystems LeadAuthor Commented:
I get a browser error saying invalid arguments
aki4uCommented:
at what line you are getting this error?
NickMalloySystems LeadAuthor Commented:
It says line 188
Invalid Arguments
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.