我需要从LinkButton打开一个弹出窗口,该窗口位于Update面板中的GridView内
我在网格视图的RowCommand
中调用此代码Dim script As String = "window.open('PopupPage.aspx, 'CommentsView', 'top=150,left=100,menubar=no,width=780,height=400,toolbar=no,resizable=no,scrollbars=yes');"
ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, Guid.NewGuid().ToString(), script, True)
但它没有打开弹出窗口,也没有出错,我该如何解决?
答案 0 :(得分:2)
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<div style="text-align: right">
<asp:HyperLink ID="details_link_m1" runat="server" onclick="window.open(this.href,this.target,'directories=no,menubar=no,resizable=no,scrollbars=1,status=no,toolbar=no,addressbar=no,fullscreen=yes'); return false;"
Target="_blank">Approve</asp:HyperLink>
</div>
</ItemTemplate>
<ItemStyle Width="45px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate))
{
string url = "";
if (((DataRowView)e.Row.DataItem).Row.ItemArray.GetValue(3).ToString() == "T1")
{
url = "Type1.aspx?Sid=" + ((DataRowView)e.Row.DataItem).Row.ItemArray.GetValue(0).ToString();
}
HyperLink details_link_m1 = (HyperLink)e.Row.FindControl("details_link_m1");
details_link_m1.NavigateUrl = url;
}
}
答案 1 :(得分:2)
答案 2 :(得分:1)
在javascript代码中缺少撇号(')(在'PopupPage.aspx'
中)。
Dim script As String = "window.open('PopupPage.aspx', 'CommentsView', 'top=150,left=100,menubar=no,width=780,height=400,toolbar=no,resizable=no,scrollbars=yes');"
答案 3 :(得分:0)
代替RegisterClientScriptBlock
使用RegisterStartupScript
,因为您想在服务器点击链接按钮加载后立即执行脚本。