Link to home
Start Free TrialLog in
Avatar of wym
wym

asked on

ASP.NET and popup windows with dynamic URLs

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?
ASKER CERTIFIED SOLUTION
Avatar of CuSo4
CuSo4

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CuSo4
CuSo4

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');")
Avatar of wym

ASKER

Thank you CuSo4.  Once I understood the problem, I could fix it!