943,884 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 6762
  • VB.NET RSS
Jun 10th, 2009
0

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

Expand Post »
Hi,

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

VB.NET Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
ypdev is offline Offline
34 posts
since Jul 2008
Jun 10th, 2009
0

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

IE - User interface uses UTF-8 character set.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jun 11th, 2009
0

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

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?
Reputation Points: 10
Solved Threads: 0
Light Poster
ypdev is offline Offline
34 posts
since Jul 2008
Jul 5th, 2009
0

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

For those who needs the same solution:

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

VB.NET Syntax (Toggle Plain Text)
  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:

VB.NET Syntax (Toggle Plain Text)
  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...
Reputation Points: 10
Solved Threads: 0
Light Poster
ypdev is offline Offline
34 posts
since Jul 2008
May 18th, 2010
0
Re: Passing unicode query string to popup window using window.open method
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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
foluis is offline Offline
5 posts
since May 2010
May 19th, 2010
0
Re: Passing unicode query string to popup window using window.open method
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.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in VB.NET Forum Timeline: Error message
Next Thread in VB.NET Forum Timeline: timer1 control





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC