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

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Jul 2008
Posts: 22
Reputation: ypdev is an unknown quantity at this point 
Solved Threads: 0
ypdev ypdev is offline Offline
Newbie Poster

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

 
0
  #1
Jun 10th, 2009
Hi,

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

  1. Dim popupScript As String = "window.open('cFinder.aspx?cName=" & c_TextBox.Text & "','', 'width=420,height=200,menubar=no,scrollbars=yes');"
  2. If (Not Page.ClientScript.IsStartupScriptRegistered("popup")) Then
  3. Page.ClientScript.RegisterStartupScript(Me.GetType(), "popup", popupScript, True)
  4. 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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,434
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 439
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

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

 
0
  #2
Jun 10th, 2009
IE - User interface uses UTF-8 character set.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 22
Reputation: ypdev is an unknown quantity at this point 
Solved Threads: 0
ypdev ypdev is offline Offline
Newbie Poster

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

 
0
  #3
Jun 11th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 22
Reputation: ypdev is an unknown quantity at this point 
Solved Threads: 0
ypdev ypdev is offline Offline
Newbie Poster

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

 
0
  #4
Jul 5th, 2009
For those who needs the same solution:

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

  1. Public Sub Redirect(ByVal url As String, ByVal target As String, ByVal windowFeatures As String)
  2. Dim context As HttpContext = HttpContext.Current
  3. If ([String].IsNullOrEmpty(target) OrElse target.Equals("_self", StringComparison.OrdinalIgnoreCase)) AndAlso [String].IsNullOrEmpty(windowFeatures) Then
  4. context.Response.Redirect(url)
  5. Else
  6. Dim page As Page = DirectCast(context.Handler, Page)
  7. If page Is Nothing Then
  8. Throw New InvalidOperationException("Cannot redirect to new window outside Page context.")
  9. End If
  10. url = page.ResolveClientUrl(url)
  11. Dim script As String
  12. If Not [String].IsNullOrEmpty(windowFeatures) Then
  13. script = "window.open(""{0}"", ""{1}"", ""{2}"");"
  14. Else
  15. script = "window.open(""{0}"", ""{1}"");"
  16. End If
  17. script = [String].Format(script, url, target, windowFeatures)
  18. ScriptManager.RegisterStartupScript(page, GetType(Page), "Redirect", script, True)
  19. End If
  20. End Sub


And in the btnSubmit sub:

  1. Session.Item("ObjToRedirect") = TextBox1.Text
  2. 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...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC