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

reset button updates appstate variable #17877

Closed OmidAtaei1362 closed 4 years ago

OmidAtaei1362 commented 4 years ago

hi. with this appstate class

        public EntryType CurrentEntryType { get; private set; } = new EntryType();

        public event Action OnChange;

        public void SetEntryType(EntryType newEntryType)
        {
            CurrentEntryType = newEntryType;
            NotifyStateHasChange();
        }

        private void NotifyStateHasChange()
        {
            OnChange?.Invoke();
        }

and Components (AddEntry)

<EditForm Model="@entryTypeState.CurrentEntryType" OnValidSubmit="@HandleValidSubmit">
    <DataAnnotationsValidator />
    <ValidationSummary />
    <div class="form-group">
        <label for="entrytype">Type</label>
        <InputText @bind-Value="@entryTypeState.CurrentEntryType.Type" class="form-control rtl" placeholder="Please Enter Type" />
    </div>
    <button type="submit" class="btn btn-primary rtl">Save</button>
    <button type="reset" class="btn btn-primary rtl">Cancel</button>
</EditForm>

and (ListEntries)

@if (entryTypes == null)
{
    <p>Loading</p>
}
else
{
    <table class="table table-striped text-center">
        <thead>
            <tr>
                <th scope="col" class="text-center">ID</th>
                <th scope="col" class="text-center">Type</th>
                <th scope="col" class="text-center">Edit</th>
                <th scope="col" class="text-center">Delete</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var entryType in entryTypes)
            {
                <tr>
                    <td>@entryType.Id</td>
                    <td>@entryType.Type</td>
                    <td><button type="button" class="btn btn-link" @onclick="@(() => Edit(entryType))">Edit</button></td>
                    <td><button type="button" class="btn btn-link" @onclick="@(() => Delete(entryType))">Delete</button></td>
                </tr>
            }
        </tbody>
    </table>
}

i click on Edit Button, change value on inputtext and then click on "Cancel" button on AddEntry Component, Related Entry on ListEntries Component updates but not inserted in DB. it must clear inputtext and doesn't change ListEntries Component

mkArtakMSFT commented 4 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 asp.net-core-blazor tag.

ghost commented 4 years ago

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

tespheakdeyesoftix commented 4 years ago

Hi @OmidAtaei1362

Did you already get the answer about this problem? I am now facing with this problem also. I have post to stack overflow but no response. I hope this team help us with Reset Button in Editform.

Thanks,

OmidAtaei1362 commented 4 years ago

On Sat, Dec 21, 2019 at 9:49 AM tespheakdeyesoftix notifications@github.com wrote:

Hi @OmidAtaei1362 https://github.com/OmidAtaei1362

Did you already get the answer about this problem? I am now facing with this problem also. I have post to stack overflow but no response. I hope this team help us with Reset Button in Editform.

Thanks,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/AspNetCore/issues/17877?email_source=notifications&email_token=ANVQN6HX3QTJHE3AQ5G4FGTQZWYNZA5CNFSM4J22UJC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHOWDHA#issuecomment-568156572, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVQN6CBNX6B5EPFYGCFZSDQZWYNZANCNFSM4J22UJCQ .

Hi. I did it too but no response. I have this problem yet. I’m working on it. :)

tespheakdeyesoftix commented 4 years ago

Too sad to heard that. I hope this team help us to solve this small problem.

OmidAtaei1362 commented 4 years ago

Hi I hope so too.

On Mon, Dec 23, 2019 at 6:27 AM tespheakdeyesoftix notifications@github.com wrote:

Too sad to heard that. I hope this team help us to solve this small problem.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/AspNetCore/issues/17877?email_source=notifications&email_token=ANVQN6CSLUHSX32W66MIH7LQ2ASH3A5CNFSM4J22UJC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHQCCHY#issuecomment-568336671, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVQN6DPPXKE7A4RN7CR3Y3Q2ASH3ANCNFSM4J22UJCQ .