Link to home
Start Free TrialLog in
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

asked on

Display model message in a div

Hi Experts,
I have the following code. I want to display the  message present in Model.UploadIssueMessages  in <li></li> under "InvaliFileFormat" div.

Thanks in advance.


<div class="validation-summary-errors" style="display:none" id="InvaliFileFormat">
         <ul>
            <li> Invalid file format! Allowed file formats are .ai,.eps,.png,.jpg and .pdf</li>
         </ul>
</div>


@if (Model.UploadIssueMessages != null)
{
    //<li></li> should display the message present in Model.UploadIssueMessages instead of a fixed message
}

Open in new window

Avatar of Kelvin McDaniel
Kelvin McDaniel
Flag of United States of America image

Assuming that Model.UploadIssueMessages is a IEnumerable of strings, you should be able to simply do the following:

@if (Model.UploadIssueMessages != null)
{
    foreach (var issueMessage in Model.UploadIssueMessages)
    {
        <li>@issueMessage</li>
    }
}

Open in new window

Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

ASKER

Hi Kelvin,
Thanks for your reply. Actually I want to display the message in the <li> tag present in the div with ID "InvaliFileFormat" .
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Kelvin McDaniel
Kelvin McDaniel
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Kelvin,
If you see my original question, I have a div already at the top of the page called "InvaliFileFormat". So I just want to display the message in that Div instead of creating a new one.

Thank you for trying to help me!
If you look closely you'll see that's exactly what I did; I moved the code from where it was to encompass the existing div In your original question and got rid of the unnecessary following code.
Thank you!