如何使用variabel中存储的ID更改图像的可见性? [英] How do I can change visibilty of my image using an Id stored in a variabel ?

查看:131
本文介绍了如何使用variabel中存储的ID更改图像的可见性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我有一个包含图像ID的数组,我想根据这些ID将其可见性更改为true,我该怎么做?

预先谢谢您!

Hi everyone !

I have an array that contains Ids of images and I want to change their visibility to true , based on these ids how can I do that please ?

Thank you in advance !

推荐答案

然后在循环内部,将字符串"v"拆分为字符串数组,然后再次循环遍历并隐藏它们逐个.

注意:您应该在ID之间使用一些分隔符.我在这里以逗号(,)作为分隔符.

像...
Then inside the Loop, split the String "v" to make it an array of strings and again Loop through them and hide them one by one.

Note: You should have some separator between the Ids. I am taking comma (,) as a Separator here.

Something like...
string[] imageIds = v.Split(',');

foreach(string id in imageIds)
{
    System.Web.UI.WebControls.Image img = (System.Web.UI.WebControls.Image)FindControl(id);
    img.Visible = false;
}


我没有尝试过此代码.让我知道,如果您遇到任何问题.


I have not tried this code. Let me know, if you face any issues.


这篇关于如何使用variabel中存储的ID更改图像的可见性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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