Esempio n. 1
0
        public ToastMessage_MvcResponseViewModel AddToastMessage(string message, ToastTypeEnum toastType, int timeout)
        {
            Timeout = timeout;
            var toast = new ToastMessage_MvcResponseViewModel
            {
                Message   = message,
                ToastType = toastType
            };

            ToastMessages.Add(toast);
            return(toast);
        }
Esempio n. 2
0
        /*-- BEGIN Toastr --*/
        public static void ShowToast(this Page page, ToastTypeEnum type, string msg, string title = "", ToastPositionEnum position = ToastPositionEnum.TopRight, bool showCloseButton = true, int timeout = 50000)
        {
            var strType     = "";
            var strPosition = "";

            switch (type)
            {
            case ToastTypeEnum.Success:
                strType = "success";
                break;

            case ToastTypeEnum.Info:
                strType = "info";
                break;

            case ToastTypeEnum.Warning:
                strType = "warning";
                break;

            case ToastTypeEnum.Error:
                strType = "error";
                break;
            }

            //Set the position based on selected and change value to match toastr plug in
            switch (position)
            {
            case ToastPositionEnum.TopRight:
                strPosition = "toast-top-right";
                break;

            case ToastPositionEnum.TopLeft:
                strPosition = "toast-top-left";
                break;

            case ToastPositionEnum.TopCenter:
                strPosition = "toast-top-center";
                break;

            case ToastPositionEnum.TopStretch:
                strPosition = "toast-top-full-width";
                break;

            case ToastPositionEnum.BottomRight:
                strPosition = "toast-bottom-right";
                break;

            case ToastPositionEnum.BottomLeft:
                strPosition = "toast-bottom-left";
                break;

            case ToastPositionEnum.BottomCenter:
                strPosition = "toast-bottom-center";
                break;

            case ToastPositionEnum.BottomStretch:
                strPosition = "toast-bottom-full-width";
                break;
            }


            //Call the toastify() function in site.js
            var script =
                $"toastify(\'{strType}\', \'{CleanStr(msg)}\',\'{CleanStr(title)}\', \'{strPosition}\', \'{showCloseButton}\', \'{timeout}\');";

            page.ClientScript.RegisterStartupScript(page.GetType(), "toastedMsg", script, true);
        }