ASP.NET中继器事件 [英] ASP.NET Repeater Events

查看:71
本文介绍了ASP.NET中继器事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个中继器,我在中继器和一个asp图像中有一个按钮,单击该按钮时我想更改asp:Image的图像URL,但是我遇到的问题是我无法在该图像中使用该图像.后面的代码,是的,它具有runat服务器属性.但是当我从中继器中取出asp图像时,便可以在代码beind中使用该图像.

请为我提供有关如何解决此问题的建议.

在此先谢谢您.

Hi guys,

I have a repeter and i got a button inside the repeater and an asp image, when the button is clicked i want to change the image url of the asp:Image, but the problem i am having is that i cannot use the image in the code behind, and yes it have the runat server attribute. But when i take the asp Image out ouf the repeater i can then use the image in the code beind.

Please advise me on how to overcome this problem.

Thanks in advance.

推荐答案

如果您想在转发器中使用asp:image按钮,那么

您需要使用查找控制方法找出该图像按钮.

为图像按钮指定命令名称,并在图像按钮中指定命令参数(作为该图像的ID).

使用中继器Item_Command事件.

并放置条件

如果(e.commandName =="commandName")
{
像您一样使用e.commandArgument.
//在此处进行更改图片网址的代码
}
If you want to use asp:image button inside repeater then

You need to find out that image button using find control method.

give command name to image button, as well as command argument (as id of that image) in image button.

Use repeater Item_Command event.

and put condition

if (e.commandName == "commandName")
{
use e.commandArgument as u like.
// do code here for change image url
}


这篇关于ASP.NET中继器事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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