简体   繁体   English

如何为图像控制执行if-else条件?

[英]How to do an if-else condition for Image Control?

How can I do an if-else condition for Image Control in ASP.NET if it is empty? 如果它是空的,如何在ASP.NET中为Image Control执行if-else条件? If it is not empty, btnSave (Button) is enabled. 如果它不为空,则启用btnSave(按钮)。

if (imageControl.Image != NULL)
{
btnSave.Enabled = true;
}

If by "empty" you mean ImageUrl is not set then 如果“空”,则表示未设置ImageUrl

if (!string.IsNullOrEmpty(imageControl.ImageUrl))
{
    btnSave.Enabled = true;
}

If by "empty" you mean ImageUrl indeed contains some meaningfull image, you have to tackle the resulting 如果“空”意味着ImageUrl确实包含一些有意义的图像,则必须解决结果

<img />

tag on client side. 在客户端标记。

asp.net imageControl has ImageUrl property where the path of the image file is located. asp.net imageControl具有ImageUrl属性,其中包含图像文件的路径。 you can check this property weather it is blank or empty as shown below: 你可以检查这个属性天气是空白还是空的,如下所示:

if(imageControl.ImageUrl!=""){
    btnSave.Enabled = true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM