protected void dlHead_ItemDataBound(object sender, DataListItemEventArgs e)
{ imgbtn += i.ToString();
if (e.Item.ItemType == ListItemType.Item)
{
ImageButton ibtn = (ImageButton)e.Item.FindControl("imgbtn1");
ibtn.Attributes.Add("onclick", "javascript:window.open('PerVip.aspx?UDM_Acc=" + ibtn.CommandArgument + "');");
}
}
<asp:DataList ID="dlHead1" CssClass="imgbtn" runat="server" OnItemDataBound="dlHead_ItemDataBound">
<ItemTemplate>
<asp:ImageButton ID="imgbtn1" runat="server" Height="50px" ImageUrl='<%# "Img_Vip\\"+Eval("head") %>'
CommandArgument='<%# Eval("UDM_Acc") %>' Width="50px" />
</ItemTemplate>
</asp:DataList>
结果 浏览器的解析代码居然是:
<input type="image" name="ctl00$cphcon3_1$dlHead1$ctl00$imgbtn1" id="ctl00_cphcon3_1_dlHead1_ctl00_imgbtn1" src="Img_Vip\8.gif" onclick="javascript:window.open('PerVip.aspx?UDM_Acc=70000');" style="height:50px;width:50px;border-width:0px;" />
</td>
</tr><tr>
<td>
<input type="image" name="ctl00$cphcon3_1$dlHead1$ctl01$imgbtn1" id="ctl00_cphcon3_1_dlHead1_ctl01_imgbtn1" src="Img_Vip\11.gif" style="height:50px;width:50px;border-width:0px;" />每格1条 onclick事件就不见了???
这是怎么回事?有什么解决方法吗???求救中!!!
{ imgbtn += i.ToString();
if (e.Item.ItemType == ListItemType.Item)
{
ImageButton ibtn = (ImageButton)e.Item.FindControl("imgbtn1");
ibtn.Attributes.Add("onclick", "javascript:window.open('PerVip.aspx?UDM_Acc=" + ibtn.CommandArgument + "');");
}
}
<asp:DataList ID="dlHead1" CssClass="imgbtn" runat="server" OnItemDataBound="dlHead_ItemDataBound">
<ItemTemplate>
<asp:ImageButton ID="imgbtn1" runat="server" Height="50px" ImageUrl='<%# "Img_Vip\\"+Eval("head") %>'
CommandArgument='<%# Eval("UDM_Acc") %>' Width="50px" />
</ItemTemplate>
</asp:DataList>
结果 浏览器的解析代码居然是:
<input type="image" name="ctl00$cphcon3_1$dlHead1$ctl00$imgbtn1" id="ctl00_cphcon3_1_dlHead1_ctl00_imgbtn1" src="Img_Vip\8.gif" onclick="javascript:window.open('PerVip.aspx?UDM_Acc=70000');" style="height:50px;width:50px;border-width:0px;" />
</td>
</tr><tr>
<td>
<input type="image" name="ctl00$cphcon3_1$dlHead1$ctl01$imgbtn1" id="ctl00_cphcon3_1_dlHead1_ctl01_imgbtn1" src="Img_Vip\11.gif" style="height:50px;width:50px;border-width:0px;" />每格1条 onclick事件就不见了???
这是怎么回事?有什么解决方法吗???求救中!!!
解决方案 »
- FindControl取不到值,为什么呢、
- 关于时间差的问题
- fckeditor再次提问,帮忙的就给分(散分)
- 请高手进来指点membership成员管理问题~~~在线等...............................
- win7 iis配置好后实现ASP的问题
- 在ASP.NET里如何实现类似ASP中的action的功能?
- 急求!!!快啊。。。。。得到答案马上结帖
- 如何实现某个目录下的文件夹共享?
- 运行ASP.NET程序时,出现加载失败,怎样解决?HELP!!!!
- "已有打开的与此连接相关联的 DataReader,必须首先将它关闭"错误
- 这段简单的代码为什么不行? 走过路过帮我看看, 谢谢!
- 请教设置html中图片尺寸的问题
服务器控件生成一个唯一的 ClientID ,ClientID 通过将子控件的父控件的 UniqueID 值与控件的 ID 值连接生成,各个部分之间以下划线 _ 连接
<input type="image" name="ctl00$cphcon3_1$dlHead1$ctl00$imgbtn1" id="ctl00_cphcon3_1_dlHead1_ctl00_imgbtn1" src="Img_Vip\8.gif" onclick="javascript:window.open('PerVip.aspx?UDM_Acc=70000');" style="height:50px;width:50px;border-width:0px;" />
</td>
</tr><tr>
<td>
<input type="image" name="ctl00$cphcon3_1$dlHead1$ctl01$imgbtn1" id="ctl00_cphcon3_1_dlHead1_ctl01_imgbtn1" src="Img_Vip\11.gif" style="height:50px;width:50px;border-width:0px;" />
</td>
</tr><tr>
<td>
<input type="image" name="ctl00$cphcon3_1$dlHead1$ctl02$imgbtn1" id="ctl00_cphcon3_1_dlHead1_ctl02_imgbtn1" src="Img_Vip\9.gif" onclick="javascript:window.open('PerVip.aspx?UDM_Acc=8a8a8A');" style="height:50px;width:50px;border-width:0px;" />
ibtn.Attributes.Add("onclientclick", "javascript:window.open('PerVip.aspx?UDM_Acc=" + ibtn.CommandArgument + "');");
ibtn.Attributes.Add("onclientclick", "javascript:window.open('PerVip.aspx?UDM_Acc=" + ibtn.CommandArgument + "');");
能给个代码吗???
谢谢!!!!
if (e.Item.ItemType == ListItemType.Item||e.Item.ItemType == ListItemType.AlternatingItem)
{
ImageButton ibtn = (ImageButton)e.Item.FindControl("imgbtn1");
ibtn.Attributes.Add("onclick", "javascript:window.open('PerVip.aspx?UDM_Acc=" + ibtn.CommandArgument + "');");
}