Search code examples
c#.netinputblazorplaceholder

How to set placeholder for InputText with bind-Value for formsubmit?


I am trying to build a InputText for Blazor which holds a placeholder if the skill is yet null so is created as a new one, since I want to use the same razor component for edit and create new skill:

      <div class="form-group">
        <label>Skillname</label>
        @if (Skill == null)
        {
          <InputText class="form-control" placeholder="Enter Skillname" @bind-Value="Skill.Name"/>
        }
        else
        {
          <InputText @bind-Value="Skill.Name" class="form-control"/>
        }
      </div>   

I tried to set placeholder=".." without having any effect. After research I found that they were using placeholder here even though it is not working for me.

I only found this possibility with telerik front end framework.

I was not able to find any reference to placeholder in the documentation.

Andy idea why placeholder is not working here or if there is any other workaround to achieve this?


Solution

  • There is no intellisense and that is what confuses people. However, if you just use the placeholder attribute it will work.

    <InputText id="lastName" class="form-control" placeholder="Last Name" @bind-Value="EmployeeVM.LastName"></InputText>