Is there a way to find if any control on page is dirty?

Lets say, as an example, I have a page and it has 15 different controls of different types. If any of them is changed by user, at the time when user tries to close the page or navigate away from the page, I need to warn the user for data loss. Is there a way of doing that within radzen or blazor?

Hi @ShishirDahal,
you can try this NuGet Package: GitHub - StevenGilligan/AutoCompare: AutoCompare is a simple library with the goal of making it effortless to compare two objects of the same type to generate the list of modified properties.
On page or dialog open clone your initial data like this (for example):

        var original    = <yourcontext>.Entry(<yourentity>).CurrentValues.Clone();
        var clone = new <yourentityclass>();
        <yourcontext>.Entry(clone).CurrentValues.SetValues(original);

Then before saving Autocompare the clone and "yourentity":

            var differences = Comparer.Compare(clone, <yourentity>);
            if (differences.Any())
            {...}

Regards
Thomas

1 Like

Thanks Thomas, I will give it a try and let you know.