Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6884873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:33:50+00:00 2026-05-27T05:33:50+00:00

I have a point in my .NET (VB) application at which the user is

  • 0

I have a point in my .NET (VB) application at which the user is prompted to select zero to many documents to be printed, which are spawned off in separate new windows.

The list of documents selected is passed in from the previous page, pipe-delimited, as part of the querystring, which is then split to create a list of documents. My code iterates through this list, builds the new window’s URL dynamically and then spawns the new window. For some reason I’m getting a maximum of two new pop-up windows, regardless of whether the user chose three or more, and the list is being populated fully and properly.

I know that I need a unique key for each window, and that is being built dynamically and appears to be working fine. Code is below. Can anyone spot my error?

TIA
Mike

If Not Request.QueryString("clttr") = Nothing Then

    Dim strURL As String
    Dim ScriptString As String
    Dim txnLttr As String
    Dim i As Integer = 0
    Dim strKey As String
    lstLetters = Split(Request.QueryString("clttr"), "|")

    For Each txnLttr In lstLetters
        strKey = "Letter" & i

        If UCase(Mid(txnLttr, Len(txnLttr) - 2, 3)) = "PDF" Then
            strURL = "PDF_Prep.aspx?Case=" & Session("SelKey") & "&COLL=" & Session("SelKey") & "&UN=" & Session("UserPKey") & "&Letter=" & txnLttr
            ScriptString = "<script language='javascript'>"
            ScriptString += "window.open('" & strURL & "', '_blank');"
            ScriptString += "</script>"
            ClientScript.RegisterStartupScript(Me.GetType, strKey, ScriptString)

        Else
           'Response.Redirect("PrtSngleLttr.asp?Case=" & Session("SelKey") & "&Letter=" & txnLttr)
           'Write code here to split the variable txnLttr into path and Letter name...Once done send appropriate params to MergeDocument.

           If txnLttr.Contains("/") Then
               Dim fileName As String
               Dim filePath As String
               Dim lastIndex As Integer = txnLttr.LastIndexOf("/")
               fileName = Right(txnLttr, txnLttr.Length - (lastIndex + 1))
               filePath = Left(txnLttr, lastIndex)
               strURL = "MergeDocument.aspx?Case=" & Session("SelKey") & "&LetterName=" & fileName & "&LetterPath=" & filePath & "&Mode=MERGE"
               ScriptString = "<script language='javascript'>"
               ScriptString += "window.open('" & strURL & "', '_blank');"
               ScriptString += "</script>"
               ClientScript.RegisterStartupScript(Me.GetType, strKey, ScriptString)

           Else
               strURL = "MergeDocument.aspx?Case=" & Session("SelKey") & "&LetterName=" & txnLttr & "&Mode=MERGE"
               ScriptString = "<script language='javascript'>"
               ScriptString += "window.open('" & strURL & "', '_blank');"
               ScriptString += "</script>"
               ClientScript.RegisterStartupScript(Me.GetType, strKey, ScriptString)
            End If
        End If
        i += 1
        Next
    Else
        Response.Redirect("CaseDetail.aspx?case=" & Session("SelKey") & "&UN=" & Header1.UserNumber)
    End If
End If
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:33:51+00:00Added an answer on May 27, 2026 at 5:33 am

    I can’t spot your exact error, but it could be that one of the values you are pulling into the URL contains an embedded quote (‘), which would destroy the javascript. Replacing any single quotes with \’ in the URL will resolve this issue.

    You are going to have a much easier time tracking the issue down if you have all of the javascript in a single block.

    In addition, your existing code creates a lot of strings, which will have an impact in a high usage scenario.

    To resolve all three of these issues, I would rewrite your code as follows:

    If Not Request.QueryString("clttr") = Nothing Then
    
        Dim ScriptString As New System.Text.StringBuilder(1000)
        lstLetters = Split(Request.QueryString("clttr"), "|")
    
        For Each txnLttr As String In lstLetters
            Dim strURL As New Sysem.Text.StringBuilder(500)
    
            If UCase(Mid(txnLttr, Len(txnLttr) - 2, 3)) = "PDF" Then
                strURL.Append("PDF_Prep.aspx?Case=").Append(Session("SelKey")).Append("&COLL=").Append(Session("SelKey")).Append("&UN=").Append(Session("UserPKey")).Append("&Letter=").Append(txnLttr)
            Else
               If txnLttr.Contains("/") Then
                   Dim fileName As String
                   Dim filePath As String
                   Dim lastIndex As Integer = txnLttr.LastIndexOf("/")
                   fileName = Right(txnLttr, txnLttr.Length - (lastIndex + 1))
                   filePath = Left(txnLttr, lastIndex)
    
                   strURL.Append("MergeDocument.aspx?Case=").Append(Session("SelKey")).Append("&LetterName=").Append(fileName).Append("&LetterPath=").Append(filePath).Append("&Mode=MERGE")
               Else
                   strURL.Append("MergeDocument.aspx?Case=").Append(Session("SelKey")).Append("&LetterName=").Append(txnLttr).Append("&Mode=MERGE")
                End If
            End If
    
            ScriptString.Append("window.open('").Append(strURL.ToString().Replace("'", "\'")).Append("', '_blank');").AppendLine()
        Next
    
        ClientScript.RegisterStartupScript(Me.GetType, "Letters", ScriptString.ToString(), True)
    Else
        Response.Redirect("CaseDetail.aspx?case=" & Session("SelKey") & "&UN=" & Header1.UserNumber)
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an .NET application which is run with default rights as the current
I have a vb.net application which does some processing. This processing can take a
I have an existing asp.net c# application for which I'd like to implement a
I have android application in which for a logged facebook user to retrieve in
EDIT: I missed a crucial point: .NET 2.0 Consider the case where I have
I have a VB.NET Windows Forms project that at one point paints text directly
I have a Sitecore/ASP.NET projects that I'm developing. Today at some point I inadvertently
I have a floating point value X which is animated. When in rest it's
I have a .NET application written in C#. My application uses 3rd party libraries,
Here's what i have : ASP.NET 4.0 Web Application Forms Authentication (Cookie Based) Here's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.