0

我想检测一组图像的图像 URL,如果任何图像 URL 是“cameraNotFound.jpg”,用户应该会收到错误消息并且应该无法单击“继续”按钮。

下面是我的代码,它最初检查图像是否在数据库中可用,它显示图像,但如果它不可用,则显示“cameraNotFound.jpg”图像。

请看下面的代码:

<div id="list">



    @for (int i = 0; i < Model.Cameras.Count; i++)
    {
        CameraDto camera = Model.Cameras[i];
        <div>
            <p>

                @if (string.IsNullOrEmpty(camera.Base64Image))
                {
                    <a class="fancybox" rel="group" id="pickheadImageLightBox" title="@camera.Name : @camera.SerialNumber" href="/Content/Images/graphics/cameraNotFound.jpg">
                        <img alt="@i" id="pickheadImage" src="/Content/Images/graphics/cameraNotFound.jpg" width="200" height="150" />
                    </a>
                }
                else
                {  
                    <a class="fancybox" rel="group" id="pickheadImageLightBox" title="@camera.Name : @camera.SerialNumber" href="@("data:image/jpg;base64," + camera.Base64Image)">
                        <img alt="@i" id="pickheadImage" src="@("data:image/jpg;base64," + camera.Base64Image)" width="200" height="150" />
                    </a>
                }
            </p>
            <p>
                <strong>@camera.Name:</strong><br />
                <span id="pickheadImageDetails">@camera.SerialNumber</span>
            </p>
        </div>
    }
</div>
<div class="clearall"></div>
<p class="redtext">Camera not found, please detect the cameras again!</p>
<div role="button" class="marginTop50 marginBottom">
    <input type="button" id="getCameraSerialNumbers" value="Detect Cameras" class="active" />
    <input type="button" id="confirmCameraSerialNumbers" value="Confirm & Proceed" disabled="disabled" class="disabled marginLeft50" />
</div>

我也尝试对@IF包含“错误消息和按钮”的语句使用相同的语句。

@if (string.IsNullOrEmpty(camera.Base64Image))
{
    <p class="redtext">Camera not found, please detect the cameras agarn!</p>
    <div role="button" class="marginTop50 marginBottom">
        <input type="button" id="getCameraSerialNumbers" value="Detect Cameras" class="active" />
        <input type="button" id="confirmCameraSerialNumbers" value="Confirm & Proceed" disabled="disabled" class="disabled marginLeft50" />
    </div>
} else
{ <div role="button" class="marginTop50 marginBottom">
        <input type="button" id="getCameraSerialNumbers" value="Detect Cameras" class="active" />
        <input type="button" id="confirmCameraSerialNumbers" value="Confirm & Proceed" class="active marginLeft50" />
    </div>
}

但它不起作用,它无法引用“相机”变量。

如果您需要任何其他信息,请告诉我。

请建议。

4

0 回答 0