Link to home
Start Free TrialLog in
Avatar of Phillie
Phillie

asked on

Datagrig window.open registerstartupscript problem

Hi All. I have just finished a contract and returned to a project I was working on. Something very odd has happened while I was away. I have a DataGrid which dispayes a set of results from our DB. The datagrid has a button called "Play". When "Play" is clicked, it should bring up a poup window displaying a "Music Player". This code below worked 3 weeks ago but is not working now. I already tried RegisterClientScriptBlock. Any bright ideas on what is happening? In advance, many thanks for all your help.

This is a stripped down version of the code:

VB.NET
####################
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dt As New DataTable
        Dim i As Integer
        Dim dr As DataRow
        dt.Columns.Add("SomeCol", System.Type.GetType("System.String"))
        For i = 1 To 4
            dr = dt.NewRow()
            dr("SomeCol") = i.ToString
            dt.Rows.Add(dr)
        Next
        DataGrid1.DataSource = dt
        DataGrid1.DataBind()
    End Sub

    Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
        If e.CommandName = "Play" Then
            Dim popupScript As String = "<script language='javascript'>" & _
            "window.open('../player/right_frame.aspx', 'Window', 'width=200, height=200');" & _
            "</script>"

            Page.RegisterStartupScript("playerPopup", popupScript)

        End If
    End Sub

###########################

HTML

##########################

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="tests_to_be_deleted_popups.aspx.vb" Inherits="bubblewap.net.tests_to_be_deleted_popups"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>tests_to_be_deleted_popups</title>
            <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
            <meta content="JavaScript" name="vs_defaultClientScript">
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
            <script language="javascript">
      </HEAD>
      <body onload="getPopping()" MS_POSITIONING="GridLayout">
      <form id="Form1" method="post" runat="server">
      <asp:Label id="Label2" style="Z-INDEX: 106; LEFT: 40px; POSITION: absolute; TOP: 272px" runat="server">Label</asp:Label>
      <asp:DataGrid id="DataGrid1" style="Z-INDEX: 105; LEFT: 24px; POSITION: absolute; TOP: 64px" runat="server"
      BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="4">
      <SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
            <ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
            <HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
            <FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
            <Columns>
            <asp:ButtonColumn Text="Play" CommandName="Play"></asp:ButtonColumn>
            </Columns>
            <PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></PagerStyle>
            </asp:DataGrid>
                 </form>
      </body>
</HTML>

###########################
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

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 Phillie
Phillie

ASKER

hi YZlat. thanks. each of the "Play" buttons is dynamic and carries a queryString with it i.e page.aspx?userID=XXXtrackID=XXX..... so it not a question of just one button. there are quite a few of them. these are generated by the fields in the datagrid i.e datagrid1.items(x).Cells(x) and repeats itself for all the retuned entries. i am not sure if btnPlay.Attributes.Add can be made dynamic in this case? any thoughts?
Phillie the code above will produce as many buttons as there are rows in the datagrid. You could also change it to a link ro a linkbutton and pass it a unique query string