Error Name Must Be Unique when creating a new Toast Notification

1 Answer 95 Views
ToastNotificationManager
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Troy asked on 15 Jan 2022, 07:33 AM

I'm just starting with the toast manager and notifications so I apologize if this is way off base. =) 

I'm simply trying to dynamically create a new notification, based off of a template I created at design time, called "myRestart".  This template is just a slightly modified News template (meaning, I've only changed some text in it really).

Dim toastNotification As RadToastNotification = toastManager.ToastNotifications("myRestart")
toastNotification.Name = "someRandomStuff12435176"
toastManager.ToastNotifications.Add(toastNotification)


When the final line of code above is run to add the notification to the manager, I get the error:

Telerik.RadToastNotificationManager.RadToastNotificationInvalidNameException: 'RadToastNotification: Name must be unqiue.'

I'm not sure what name it would be referring to other than the name property, which as you can see above I changed to some random text and still get the error.

Thank you for any help you can provide!

1 Answer, 1 is accepted

Sort by
1
Accepted
Stoyan
Telerik team
answered on 17 Jan 2022, 07:54 AM

Hi Troy,

As far as I see from the code you've posted, the problem is that you are getting the "myRestart" notification from the manager. Then you are changing its name and in the end you are adding it again to the manager, where it still exists and that is why it is throwing the exception. 

The same reference is added to the original toast notification to the collection and since it is the same notification again, it will have the same name and it will throw this exception. You do not need to add it again. Once you change its name it will be updated in the collection.

If you have more questions, do not hesitate to write back :-)

Regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 17 Jan 2022, 07:37 PM

Stoyan,  Thanks, that makes sense, thank you for your response.  I'm going to play around more with this (I really like the functionality of the component), and I'm sure I'll have more questions soon. =)

Tags
ToastNotificationManager
Asked by
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Stoyan
Telerik team
Share this question
or