Gridview中带有“图像"按钮的弹出窗口问题 [英] Popup Window problem with Image button in Gridview

查看:47
本文介绍了Gridview中带有“图像"按钮的弹出窗口问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我创建了一个要在Gridview中打开的弹出窗口.但是我无法在第一次单击时获得弹出窗口,而在第二次单击时却出现.

代码如下:

Hi friends,

I have created a popup window to be opened in Gridview.But i am unable get popup window for the first click, it appears for the second click.

The code as follows:

int index = Convert.ToInt32(e.CommandArgument);
index = index % GridView1.PageSize;
GridViewRow row = GridView1.Rows[index];
Image img = (Image)row.FindControl("imgSMS");
               
img.Attributes.Add("onclick","window.open('http://localhost:50807/Admin/Default.aspx','_blank','toolbar=0,location=0,menubar=0,resizable=0,height=300,width=300');return false");


需要您的帮助.
谢谢大家.


Need your help.
Thanking you all.

推荐答案



这是因为您在第一次单击时添加了javascript.在第二次单击时,JavaScript已存在,因此正在执行.您必须提前添加脚本(例如,在绑定时).不过,最简单的方法是添加
该JavaScript到您的标记.

希望对您有帮助

忘了:除此之外,您可以立即运行脚本,而无需使用onlick处理程序. Google for"asp.net javascript RegisterStartupScript"或将其写入您的响应流
Hi,

this is because you add the javascript at that first click. At the second click, the javascript is existing and therefore being executed. You have to add the script earlier (e.g. on binding). The easiest way though would be to add
that javascript to your markup.

Hope that helps

Forgot: In addition to that, you could run your script immediatly without using the onlick handler. Google for "asp.net javascript RegisterStartupScript" or write it to your response stream


此代码将在首次点击时被执行.因此,按钮的onclick属性将仅从第二次开始生效.因此,您可以在像这样的行数据绑定事件上为图像"按钮添加onclick属性..

this code will be excuted on first click. So, the onclick attribute for the button will affect only from the second time. So, You add onclick attribute for the Image button on Row data bound event like this..

// on row data bound event

 if(e.Row.RowType == DataControlRowType.DataRow)
 {
      Image img = (Image)e.Row.FindControl("imgSMS");
      img.Attributes.Add("onclick","window.open('Admin/Default.aspx','_blank','toolbar=0,location=0,menubar=0,resizable=0,height=300,width=300');return false");
 
 }



希望它能工作..



hope it works..


这篇关于Gridview中带有“图像"按钮的弹出窗口问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆