954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Passing unicode query string to popup window using window.open method

Hi,

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?

Thanks.

ypdev
Light Poster
34 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

IE - User interface uses UTF-8 character set.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

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?

ypdev
Light Poster
34 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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
            context.Response.Redirect(url)
        Else
            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}"");"
            Else
                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.

Enjoy...

ypdev
Light Poster
34 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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?

foluis
Newbie Poster
5 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

foluis

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.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You