locked
add an conditional attribute RRS feed

  • Question

  • User-1725652363 posted

    Hi,

    I have an input and I want to test before I make an attribute, this is what I did: 

    <input type="email" class="form-control" id="groupe" @(myClass.att == "" ? placeholder="placeholder" :value="a value")>

    But it's not working for me, any help please?

    Thanks in advence, 

    Monday, May 14, 2018 4:40 PM

Answers

  • User-369506445 posted

    hi

    please try below code :

    @if (myClass.att == "")
    {
        <input type="email" class="form-control" id="groupe"  placeholder = "placeholder"  >
    
    }
    else
    {
        <input type="email" class="form-control" id="groupe"  value = "a value">
    
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 5:19 PM
  • User-369506445 posted

    also you can try this

    <input type="email" class="form-control" id="groupe" placeholder="@(myClass.att == "" ? "placeholder":"")" value="@(myClass.att == "" ? "":"a value")" />
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 5:28 PM

All replies

  • User-369506445 posted

    hi

    please try below code :

    @if (myClass.att == "")
    {
        <input type="email" class="form-control" id="groupe"  placeholder = "placeholder"  >
    
    }
    else
    {
        <input type="email" class="form-control" id="groupe"  value = "a value">
    
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 5:19 PM
  • User-1725652363 posted

    Yes it's work thank you so much

    Monday, May 14, 2018 5:27 PM
  • User-369506445 posted

    also you can try this

    <input type="email" class="form-control" id="groupe" placeholder="@(myClass.att == "" ? "placeholder":"")" value="@(myClass.att == "" ? "":"a value")" />
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 5:28 PM