在GridView模版列上有个ImageButton用于弹出对话框 弹出代码为
function strnull()
{
window.showModalDialog("AwardPunishmentInsert.aspx",,window,'dialogwidth:300px; dialogheight:220px; center:yes; Help:No; Resizable:No; Status:Yes; Scroll:no; Status:no; resizable:no');
}
后台调用为
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            for (int i = 0; i < Title_Grid.Rows.Count; i++)
            {
                ImageButton IB = (ImageButton)Title_Grid.Rows[i].Cells[0].FindControl("ImageButton1");
                IB.Attributes.Add("OnClick", "Javascript:return strnull();");
            }
        }问题就是我弹出的这个AwardPunishmentInsert.aspx里面的按钮不响应任何事件,怎么点都没反映.大家有没遇到过啊.

解决方案 »

  1.   

    模板列就可以用onClientclick指定JS事件
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButton1" runat="server" onclientclick="strnull()" />
                    </ItemTemplate>
                </asp:TemplateField>
      

  2.   

    JS也有点错。
    function strnull() 

    window.showModalDialog("AwardPunishmentInsert.aspx",window,'dialogwidth:300px; dialogheight:220px; center:yes; Help:No; Resizable:No; Status:Yes; Scroll:no; Status:no; resizable:no'); //,,window 多了","号
    }
      

  3.   

    页面直接调用strnull(),不用后台
      

  4.   

    不是调用的错误,是调用出来后的AwardPunishmentInsert.aspx页面有问题,但我知道问题出在哪,各种调用方法我都试了,出来后都是一个结果,点按钮没任何反映. 不知道什么原因.
      

  5.   

    window.showModalDialog("AwardPunishmentInsert.aspx",,window,'dialogwidth:300px; dialogheight:220px; center:yes; Help:No; Resizable:No; 
    ------------
    多了一个“,”不是吗?改成这样:window.showModalDialog("AwardPunishmentInsert.aspx",window,'dialogwidth:300px; dialogheight:220px; center:yes; Help:No; Resizable:No; 
      

  6.   

    你确定ImageButton1_Click被正确的执行了吗?如果正确执行了,可能问题不在这里,因为我测试代码没问题。
      

  7.   

    showModalDialog的参数问题吧!!
      

  8.   

    试一下:
    window.showModalDialog("AwardPunishmentInsert.aspx",window,'dialogwidth:300px; dialogheight:220px; center:yes; Help:No; Resizable:No;
      

  9.   

    lz的意思是弹出AwardPunishmentInsert.aspx这个页面后.
    这个页面内的按钮点了没反应?
      

  10.   

    11楼,我没QQ啊!公司不准用QQ,因为项目赶得紧,所以前几天把MSN也给禁了,为此我还找我门部门经理协商过,不过协商未果,  还是说下你的MSN吧  我的MSN:[email protected].
      

  11.   

    问题又来了,是不是window.showModalDialog("AwardPunishmentInsert.aspx")这样打开窗体有问题啊,怎么感觉程序好象是把AwardPunishmentInsert当做一个静态html页面处理一样,只能进行显示,而不能在里面做插入数据操作,因为当我点里面的插入数据按钮的时候他不在自身进行操作,而是重新打开一个AwardPunishmentInsert窗体,在新打开的AwardPunishmentInsert里面执行数据库操作.
      

  12.   

    <asp:TemplateField HeaderText="编辑">
         <ItemTemplate>
           <asp:ImageButton ID="ImageBut"  runat="server" ImageUrl="~/images/Nav/rename_sbutton.gif"   OnClientClick="strnull()"/>
         </ItemTemplate>
           </asp:TemplateField>
    17楼是不是这个意思` 直接调用. 这个也试了.结果和            
    for (int i = 0; i < Title_Grid.Rows.Count; i++)
                {
                    ImageButton IB = (ImageButton)Title_Grid.Rows[i].Cells[0].FindControl("ImageBut");
                    IB.Attributes.Add("OnClick", "Javascript:return showMode();");
                }
    这样写的结果一样.
      

  13.   

    在head里面加<base target="_self">
      

  14.   

    你需要先将JS注册在HEAD标签里!
      

  15.   


    说明一下:由于是弹出对话框的默认目标是它的父窗口,也就是说,你点击按钮所发生的动作会被父页面接收和执行,所以会造成没有任何响应,<base target="_self">的作用是重设默认目标