?
Solved

ASP.NET and popup windows with dynamic URLs

Posted on 2003-10-30
3
Medium Priority
?
790 Views
Last Modified: 2010-08-05
Hi there:

Newbie here and I must not be understanding something fundamental.

I can pop up a window if I RegisterClientScriptBlock in the Page_Load method.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim popupScript As String = "<script language='JavaScript'> function DoClick(){ window.open('test.aspx','PopUp','location=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes') }<" & "/script>"
        Page.RegisterStartupScript("PopupScript", popupScript)

'snip

End Sub

This works fine but I want to give a name-value pair like test.aspx?name=value.  Value will be found by firing a MenuItemClicked event, which will then read the contents of a cell of an active row of a grid.

Private Sub UltraWebMenu1_MenuItemClicked(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebNavigator.WebMenuItemEventArgs) Handles UltraWebMenu1.MenuItemClicked

Dim row As Infragistics.WebUI.UltraWebGrid.UltraGridRow
Dim iProfileKey As Integer

Select Case e.Item.Text

case "Profile"
  row = UltraWebGrid1.DisplayLayout.ActiveRow
  iProfileKey = CInt(row.Cells(0).Text)

  Dim popupScript As String = "<script language='JavaScript'> function DoClick(){ window.open('test.aspx?=iProfileKey" & iProfileKey & "','PopUp','location=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes') }<" & "/script>"
        Page.RegisterStartupScript("PopupScript", popupScript)

end Select

End Sub

However, this doesn't work.  How can you popup a window given a dynamic URL?  Must RegisterClientScriptBlock be in Page_Load?
0
Comment
Question by:wym
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
CuSo4 earned 200 total points
ID: 9654134
The problem is that your JavaScript have to be constructed BEFORE the MenuItemClicked event is fired. In your code it's only constructed after the MenuItemClicked event is clicked, so it has no effect, because the JavaScript DoClick() method is called before the postback to the server, and thus before that the MenuItemClicked event click is runned.
So what happens when I click on the MenuItem:

1.) The Javascript DoClick() function is called. (which, in this case does not exists, because it haven't be created yet)
2.) The Page is posted back to the server, and the Page_Load method is fired
3.) Your UltraWebMenu1_MenuItemClicked method is fired
4.) The HTML-code is constructed and sent back to the client. (At this point your javascript will probably exist too, but it won't be a dynamic url, it will be the url that was generated on the previous postback...)
0
 
LVL 2

Expert Comment

by:CuSo4
ID: 9654178
I don't know exactely if it works with UltraWebGrid, but I know for a button you can easily create a popup using a dynamic url. If e.g. your button is named "btnMenu", you can add this code to your Page_Load:

//Generate some code that will create the url and store it in dynURL

btnMenu.Attributes.Add("onClick", "javascript:window.open('" & dynURL & "','_blank','width=400,height=550, left=312,top=100');")
0
 

Author Comment

by:wym
ID: 9658010
Thank you CuSo4.  Once I understood the problem, I could fix it!
0

Featured Post

Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question