ID Notification NotificationText NotificationTimeInterval
1 FillLog Fill the time log 9000
2 CheckMesg Check the message 500
3 Print Print report 3000
Each notifications need to appear based on this table at the specified NotificationTimeInterval and the notifications should be created programatically since the number of records in the table itself is varying. Can someone point me to the right direction or with a sample project on how to accomplish this?
Thanks,
Meera
11 Answers, 1 is accepted
Hi Meera,
You can create the controls programmatically according to your data. Here is a really simple example:
protected
void
Page_Init(
object
sender, EventArgs e)
{
var data = GetData();
//get your actual data and loop through it
for
(
int
i = 0; i < data.Rows.Count; i++)
{
CreateNotification(data.Rows[i][
"Notification"
].ToString(), data.Rows[i][
"NotificationText"
].ToString(), Int32.Parse(data.Rows[i][
"NotificationTimeInterval"
].ToString()), Placeholder1);
}
}
protected
void
CreateNotification(
string
id,
string
text,
int
interval, PlaceHolder container)
{
RadNotification rn =
new
RadNotification();
rn.ID = id;
rn.ShowInterval = interval;
rn.Text = text;
rn.KeepOnMouseOver =
false
;
rn.Width = Unit.Pixel(300);
rn.Height = Unit.Pixel(200);
if
(id ==
"CheckMesg"
)
{
rn.Position = NotificationPosition.BottomCenter;
}
else
{
rn.Position = NotificationPosition.Center;
}
//set other properties as needed
container.Controls.Add(rn);
}
protected
DataTable GetData()
{
DataTable tbl =
new
DataTable();
tbl.Columns.Add(
new
DataColumn(
"Notification"
));
tbl.Columns.Add(
new
DataColumn(
"NotificationText"
));
tbl.Columns.Add(
new
DataColumn(
"NotificationTimeInterval"
));
tbl.Rows.Add(
new
object
[] {
"FillLog"
,
"Fill the time log"
, 9000 });
tbl.Rows.Add(
new
object
[] {
"CheckMesg"
,
"Check the message"
, 500 });
tbl.Rows.Add(
new
object
[] {
"Print"
,
" Print report"
, 3000 });
return
tbl;
}
Regards, Marin Bratanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

I have another question. For ShowInterval property, instead of setting an interval, is there a way to use a time stamp directly. For example, to run the notification every day at 21:47:29.000. Or the only option i have is to convert the time into interval duration in milliseconds?
Thanks,
Meera
Hello Meera,
The ShowInterval takes an interval in milliseconds that is counted from the time the notification client-side object is created until it is shown, then reset and counted again. It is not possible to set an exact time of day to show it on. If you would like to see such a feature implemented, I suggest you post it in our feedback portal (http://feedback.telerik.com/Project/108/) together with a detailed description of the expected behavior and the way you would like to use it. If it becomes popular, we will consider its implementation.
Regards,
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

As you suggested, i have posted a feature request in the portal (http://feedback.telerik.com/Project/108/Feedback/Details/136825-radnotification-for-a-particular-time-of-day). Meanwhile, could you suggest a workaround for this? I am assuming, if i need to run a notification for a particular time of day, the ShowInterval value will be 24 hours in milliseconds, but how can i ensure that it starts at that time?
Thanks,
Meera
Hello Meera,
The workaround I can suggest is to use the Value property of the control to store the desired time (e.g., 09:00). ON the client, in the Sys.Application.Load event, get a reference to the control, get the current time and calculate their difference in milliseconds. This would be the time that needs to pass between the time the control initializes and the time it has to show up. Then, set it to the ShowInterval property via the client-side API of the control.
Regards,
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Is there a way to do exactly that BUT without place holder.
I am trying to have a utility which will take is parameters for RadNotification like title, text and stuff including Page. Goal is to have something static so that from anywhere in application i can just say RadNotificationUtility.ShowRadNotification(title, message, this.Page); and it shows me the notification.
something like this:
public static void ShowRadNotification(string title, string message, Page pageToDisplayItOn){
RadNotification radNotice = (RadNotification)(sender.FindControl("DynamicallyCreatedRadNotification"));
if(radNotice == null){
radNotice = new RadNotification();
radNotice.ID = "DynamicallyCreatedRadNotification";
pageToDisplayItOn.Controls.Add(radNotice);
}
//set other attributes of radNotice here....
string functionCall = "var dynNotice = $find('<%= DynamicallyCreatedRadNotification.ClientID %>');"
+ "if(notification != null){notification.show();} window.alert(\"i am here\");"
ScriptManager.RegisterClientScriptBlock(pageToDisplayItOn, pageToDisplayItOn.GetType(), Guid.NewGuid().ToString(), functionCall, true);
}
At this point i can see the alert i added of "I am here" but i do not see the notification..
It seems that the JS code is executed too early, before the notification client-side object was created, so $find() returns null. You need to use the Sys.Application.Load event for that:
- https://docs.telerik.com/devtools/aspnet-ajax/general-information/get-client-side-reference#important-ms-ajax-events
- https://docs.telerik.com/devtools/aspnet-ajax/controls/window/troubleshooting/executing-javascript-code-from-server
I can also suggest that you consider using the built-in server-side .Show() method of the notification. You can see how its two overloads work in the following demo: https://demos.telerik.com/aspnet-ajax/notification/examples/servershowwithnewtext/defaultcs.aspx.
Regards,
Marin Bratanov
Progress Telerik

Thank you for fast reply and your time, i highly appreciate it.
I tried sys.application.load , .Show on server side, .show on client side..
Main problem that i THINK i am having is $find giving back null if not ran that initial page load because i tried (just for debugging and experimental purpose) to add <telerik:RadNotification ..... /> in my .ascx file., so dynamically adding seems to be like not the problem however $find NOT finding it seems like the problem.. in debug mode i can see controls of the page update to include radNotification but $find either never finds and returns it or query just doesnt get executed.
additional information if it helps.. on .ascx autoeventwireup = false;
button being clicked is like this: asp:button ID="xyz" text="abc" runat=server onClick="doOnClick" UseSubmitBehavior="false"
tooltip="some info"
You should remove the markup code blocks as they are resolved only when the script is rendered from the server. You should use something like string.Format() to put the ClientID in the script. For example:
string
functionCall =
string
.Format(
"var dynNotice = $find('{0}');"
, DynamicallyCreatedRadNotification.ClientID);
Regards,
Marin Bratanov
Progress Telerik

hello Marin,
I tried your suggestions and more but it just doesnt seem to work.. moreover, "RadNotification radNotice = (RadNotification)(pageToDisplayItOn.FindControl("DynamicallyCreatedRadNotification"));" doesnt return me anything even if i RadNotification or anything in html of that page. I did test that radNotice is being added by setting visibleOnPageLoad = true and making it crash in JS (regular postback doesnt work). I created a trial project but i cannot attach zip files so i am attaching screenshot of two simple files. At this point i am not sure what i am missing or doing wrong.
Screenshots are notoriously hard to debug so I would encourage you to open a support ticket and send us the relevant files.
In the meantime, you can also look into the following:
- having a RadNotification in the master page markup will make it very easy to call its .Show(newText) method from any content page or user control. Thus, this may make it much easier for you
- I am not sure what goes wrong with a full postback, but if that does not work, partial postback will not work either. As a general rule of thumb, make sure you re-create the notification control with each postback, preferably in the Page_Init event, like with any other dynamically created control.
- Place the script manager before any script controls that need it, having it as the first control in the <form> is usually the safest approach.
Regards,
Marin Bratanov
Progress Telerik