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("Syste m.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(ByVa l source As Object, ByVal e As System.Web.UI.WebControls. DataGridCo mmandEvent Args) Handles DataGrid1.ItemCommand
If e.CommandName = "Play" Then
Dim popupScript As String = "<script language='javascript'>" & _
"window.open('../player/ri ght_frame. aspx', 'Window', 'width=200, height=200');" & _
"</script>"
Page.RegisterStartupScript ("playerPo pup", popupScript)
End If
End Sub
########################## #
HTML
##########################
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="tests_to_be_de leted_popu ps.aspx.vb " Inherits="bubblewap.net.te sts_to_be_ deleted_po pups"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>tests_to_be_deleted _popups</t itle>
<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_defaultClientScri pt">
<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"></Sele ctedItemSt yle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemSt yle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></Head erStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></Foot erStyle>
<Columns>
<asp:ButtonColumn Text="Play" CommandName="Play"></asp:B uttonColum n>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></Page rStyle>
</asp:DataGrid>
</form>
</body>
</HTML>
########################## #
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("Syste
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(ByVa
If e.CommandName = "Play" Then
Dim popupScript As String = "<script language='javascript'>" & _
"window.open('../player/ri
"</script>"
Page.RegisterStartupScript
End If
End Sub
##########################
HTML
##########################
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="tests_to_be_de
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>tests_to_be_deleted
<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_defaultClientScri
<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:
<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"></Sele
<ItemStyle ForeColor="#330099" BackColor="White"></ItemSt
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></Head
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></Foot
<Columns>
<asp:ButtonColumn Text="Play" CommandName="Play"></asp:B
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></Page
</asp:DataGrid>
</form>
</body>
</HTML>
##########################
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
ASKER