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 can i set the text for a label in razor page using "if" condition?

I have the following

<label for="source" class="col-md-2 control-label">SourceFolder</label>

I have a value in the javascript , filed is called eventtype.
I am trying to do the following

<label for="source" class="col-md-2 control-label">eventtype == 2 ? SourceDirectory 
 :SourceFolder</label>

How can i do this using ternary operator ?

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

>Solution :

For eventtype is a js variable,you can only use if in js.Here is a demo:

<label id="myLable" for="source" class="col-md-2 control-label">SourceFolder</label>

js:

<script>
var eventtype=2;
$(function() {
            var data = eventtype == 2 ? "SourceDirectory" : "SourceFolder";
            document.getElementById("myLable").innerHTML = data;
        })
</script>
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