dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.36k stars 9.99k forks source link

Disabled Property don't work with c# boolean property. & ValueChanged Not Fired #10085

Closed WojcikMM closed 5 years ago

WojcikMM commented 5 years ago

Describe the bug

When you add : <button onclick="@ChangeButton" id="create-group-btn" type="submit" class="btn btn-primary @_disabled" disabled="@(!costam)">Add Group</button> className @_disabled was changed but disabled property not appeard. I Try in few configuration and few html tags and dont work too. Also try with method this.StateHasChanged(); - the same result.

Additionaly I try to use InputText Component Property ValueChanged but it not work too -Never fires.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core '3.0.100-preview4-011223'
  2. Add Blazor file (sample.razor) with content
    
    <EditForm Model="Group">
    <DataAnnotationsValidator />
    <div class="form-group">
        <label for="name">Name</label>
        <InputText bind-Value="@Group.Name" ValueChanged="@ChangeButton" Class="form-control" Id="name" />
    </div>
    <button  onclick="@ChangeButton" id="create-group-btn" type="submit" class="btn btn-primary @_disabled" disabled="@@is">Add Group</button>
    </EditForm>

@functions{ string _disabled => isDisabled ? "disabled" : null;

Timers.Shared.Models.Group Group = new Timers.Shared.Models.Group();
public bool isDisabled = false;

public void ChangeButton()
{
    Console.WriteLine(Group.Name);
    isDisabled = !isDisabled;
    this.StateHasChanged();
}

}



### Expected behavior
When I type text or Click Button  - button may change proprty to disabled / enabled - it depends on proprty "isDisabled".

Disabled button Property may change too when I change value of InputText component. Becouse I Declare action for property ValueChanged. 

### Additional context
Add any other context about the problem here.
Include the output of `dotnet --info`
Zestaw .NET Core SDK (odzwierciedlenie dowolnego pliku global.json):
 Version:   3.0.100-preview5-011568
 Commit:    b487ff10aa

Środowisko uruchomieniowe:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview5-011568\

Host (useful for support):
  Version: 3.0.0-preview5-27626-15
  Commit:  61f30f5a23

.NET Core SDKs installed:
  2.1.700-preview-009601 [C:\Program Files\dotnet\sdk]
  2.1.700-preview-009618 [C:\Program Files\dotnet\sdk]
  2.2.300-preview-010050 [C:\Program Files\dotnet\sdk]
  2.2.300-preview-010067 [C:\Program Files\dotnet\sdk]
  3.0.100-preview4-011223 [C:\Program Files\dotnet\sdk]
  3.0.100-preview5-011568 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview5-19227-01 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview5-27626-15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview5-27626-15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
mkArtakMSFT commented 5 years ago

Hi. It looks like this is a question about how to use ASP.NET Core. While we do our best to look through all the issues filed here, to get a faster response we suggest posting your questions to StackOverflow using the blazor tag.