locked
Check if image exists on the frontend razor page RRS feed

  • Question

  • User-973886032 posted

    hi guys

    how do i check if an image exists on my frontend razor page ? (in yellow below)

    I can easily check on the server side, but I want this code done on the client side

    As my images are dynamically loaded from the database

    Here is my code

      @for (i = i + 1; i < Model.Count(); i++)
                            {
    
                                      image = (Model[i].Category_Name).Trim();
                            image = image.Replace(" ", "_");
                             image = image.Replace(".", "_");
                             image = image.Replace(":", "_");
                            image = image + ".png";
     
                                <div class="col-md-4 text-center div_for_col4   classify">
                                    <a href="Categories/ ">
                                        <h3>
                                            @Model[i].Category_Name<br /></h3>
                                        <span>
    
                                            <img src="~/images/Department_Categories/templates/@image2/@image" alt="@(Model[i].Category_Name)" width="200" class="img-fluid" />
                                            <br />
    
                                            <br />@Model[i].Description_Short
    
                                        </span><br />
                                            <br />
    
    </a><hr class="horizontal-rule-blue" />
                                </div>
    
    
                            }
    Thursday, August 15, 2019 4:08 PM

All replies