Base solution for your next web application
Open Closed

Alerts in Asp.Net Core Angular #6113


User avatar
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


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    mdframe created

    Where might I locate an example?

  • User Avatar
    0
    hitaspdotnet created

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

  • User Avatar
    0
    mdframe created

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

  • User Avatar
    0
    ismcagdas created
    Support Team

    @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).

  • User Avatar
    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

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @mdframe

    ABP Doesn't have such a feature. You need to do it on the client side by yourself using the success handler of the ajax request.