I am trying to pass query string from one page to popup window as follow:

Dim popupScript As String = "window.open('cFinder.aspx?cName=" & c_TextBox.Text & "','', 'width=420,height=200,menubar=no,scrollbars=yes');"
If (Not Page.ClientScript.IsStartupScriptRegistered("popup")) Then
Page.ClientScript.RegisterStartupScript(Me.GetType(), "popup", popupScript, True)
End If

The popup window comes up very well only if the text I typed is in english. otherwise the popup window comes up empty and the string I see in the "view source" option (in IE) is "%ufffd%%ufffd...."

I will need to query some unicode characters.

Any idea?


Recommended Answers

IE - User interface uses UTF-8 character set.

Jump to Post

All 5 Replies

IE - User interface uses UTF-8 character set.

I understand but when I redirect the query response to anotherpage.aspx instead of "popup" (window.open) it works fine and the string is as I typed it.

I am trying to understand what is the diff. between popup and standard page in terms of encoding.

Anything I missing in my code?

For those who needs the same solution:

I found a VB function that "convert" 'response.redirect' to popup window...

Public Sub Redirect(ByVal url As String, ByVal target As String, ByVal windowFeatures As String)
        Dim context As HttpContext = HttpContext.Current
        If ([String].IsNullOrEmpty(target) OrElse target.Equals("_self", StringComparison.OrdinalIgnoreCase)) AndAlso [String].IsNullOrEmpty(windowFeatures) Then
            Dim page As Page = DirectCast(context.Handler, Page)
            If page Is Nothing Then
                Throw New InvalidOperationException("Cannot redirect to new window outside Page context.")
            End If
            url = page.ResolveClientUrl(url)
            Dim script As String
            If Not [String].IsNullOrEmpty(windowFeatures) Then
                script = "window.open(""{0}"", ""{1}"", ""{2}"");"
                script = "window.open(""{0}"", ""{1}"");"
            End If
            script = [String].Format(script, url, target, windowFeatures)
            ScriptManager.RegisterStartupScript(page, GetType(Page), "Redirect", script, True)
        End If
    End Sub

And in the btnSubmit sub:

Session.Item("ObjToRedirect") = TextBox1.Text
            Redirect("NextPage.aspx", "_blank", "width=200,height=200,menubar=no,scrollbars=yes")

Of course, you'll have to translate the session item on NextPage.aspx if you need to make a query.


That only works if the new page is in the same directory that the original page.
Any ideas if i want to open a page in a different folder of than the original page?


Please do not resurrect old/solved threads.If you have any questions please ask. .... You are welcome to start your own threads.

Please read the rules before posting again - http://www.daniweb.com/forums/thread78223.html and rules.

Thread Closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.