Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to delete/hide in IF-ELSE statment previouse statements in HTML

How can I make that so it will work only one condition at one time? Basically there is a time when A,B, and C can be pick at one time all of them. Example: So if you pick A there should be only one posibility and it is "else if (A != null)", but if there is A and B it should display only "else if (Model.B != null)", but if it is A,B, and C it should display only "else if (Model.SoldOut != null)". So is there any way to do that? Or is there any way to delete A when it display B, and delete A and B when it displays C?

            @if (A == null & B == null & C == null)
            {
                @Resources.Undefined;
            }
            else if (A != null)
            {
                @Resources.ResourceManager.GetString(Model.A.GetDisplayValue());
            }
            else if (Model.B != null)
            {
                @Model.B
            }
            else if (Model.SoldOut != null)
            {
                <p>-</p>
            }

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can do it by changing the order of else if statements

 @if (A == null & B == null & C == null)
 {
     @Resources.Undefined;
 }
 else if (Model.SoldOut != null)
 {
     <p>-</p>
 }
 else if (Model.B != null)
 {
     @Model.B
 }
 else if (A != null)
 {       
     @Resources.ResourceManager.GetString(Model.A.GetDisplayValue());
 }
       
        
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading