• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

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
0
NickMalloy
Asked:
NickMalloy
  • 5
  • 5
1 Solution
 
aki4uCommented:
try to cahange  lit1.Text = sb.ToString

with this:

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

where is your page 'testsens.aspx'?

did you disabled javascript?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
NickMalloyAuthor 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
0
 
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
0
 
NickMalloyAuthor Commented:
2.0
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
0
 
NickMalloyAuthor Commented:
I get a browser error saying invalid arguments
0
 
aki4uCommented:
at what line you are getting this error?
0
 
NickMalloyAuthor Commented:
It says line 188
Invalid Arguments
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now