Open Closed

Alerts in Asp.Net Core Angular #6113


0
mdframe created

I am using the latest version of ANZ and trying to locate documentation for alerting users, everything I found is for MVC. I need to validate a serial number entered is not a duplicate before dialog submission. What is the recommended process for alerting requiring a web api call? A sample would be great as I am still very new to the framework.

Thx


6 Answer(s)
  • 0
    ismcagdas created

    Hi @mdframe

    If you are using ASP.NET Core & Angular version, you can just throw UserFriendlyException on the server side and Angular client will show this error message to user.

  • 0
    mdframe created

    Where might I locate an example?

  • 0
    csbeginner created

    if (boo > foo) { throw new UserFriendlyException(L("FOO_Warn_SizeLimit", AppConsts.MaxFooSize)); }

  • 0
    mdframe created

    How do I about getting the JSON code value from the exception in the Angular TS component?

  • 0
    ismcagdas created

    @mdframe

    If you throw UserFriendlyException, you don't need to interfere to the process at all. If you want to get a value from response and do the necessary action by yourself, you can just return a Dto class to the client and check the value of it's specific fields (errorCode for example).

  • 0
    mdframe created

    I have found whether I use UserFriendlyException from the server side or abp.message.warn from the client side the DOM does not honor my elementref.focus() method and moves to the next input field. If I use a typical alert() message the focus request is honored. Any ideas how to get the cursor back to the same element that the error was generated? Does ABP have any function or utilities to help with this type of situation? I am open to any suggestions.

    Thx