Solved

ASP.NET and popup windows with dynamic URLs

Posted on 2003-10-30
3
788 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 50 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

726 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