Hi,
am using telerik notification for client-side validation. i have a rad button in my aspx page like this:
and a telerik notification like this:
i'm trying to validate my fields one by one in a JScript file. but for simplicity let's say i just want to display "Hello World" in the telerik notification using the "ValidateJScript()" Java Script function like this:
first problem i encountered was that "set_text" method didn't work, and so i used ".text =" and that worked. Same goes for "set_title".
i made sure that ".text =" worked using the "alert(notification.text); statement. However,"notification.show();" never got executed at all, and i was never able to show the notification at all. moreover, if i add some test alert message after the "notification.show();" statement it never gets executed either. so can anyone help me and tell me how to get the notification to show using javascript in my scenario, and why did the "set_text" and "set_title" methods never worked here? thanks!
am using telerik notification for client-side validation. i have a rad button in my aspx page like this:
<telerik
:RadButton
ID
=
"testButton"
runat
=
"server"
Text
=
"Click Me!"
OnClientClicking
=
"ValidateJScript();"
></
telerik:RadButton
>
<
telerik:radnotification
id
=
"notification"
runat
=
"server"
> </
telerik:radnotification
>
i'm trying to validate my fields one by one in a JScript file. but for simplicity let's say i just want to display "Hello World" in the telerik notification using the "ValidateJScript()" Java Script function like this:
function
ValidateJScript() {
var
notification = $find(
'<%=RadNotification.ClientID %>'
);
var
message =
'Hello World'
;
notification.text = message;
alert(notification.text);
notification.show();
i made sure that ".text =" worked using the "alert(notification.text); statement. However,"notification.show();" never got executed at all, and i was never able to show the notification at all. moreover, if i add some test alert message after the "notification.show();" statement it never gets executed either. so can anyone help me and tell me how to get the notification to show using javascript in my scenario, and why did the "set_text" and "set_title" methods never worked here? thanks!
6 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 29 Oct 2012, 10:20 AM
Hi Tom,
I tried to replicate the issue in 2012, 3, 1016, 35 version and is working as expected at my end. Following is the sample code that I tried which worked as expected.
ASPX:
JS:
I also advise that you upgrade to the latest version, as there have been some fixes on the RadNotification control and they may help you, as I am not sure exactly what and how you are using.
Hope this helps.
Regards,
Princy.
I tried to replicate the issue in 2012, 3, 1016, 35 version and is working as expected at my end. Following is the sample code that I tried which worked as expected.
ASPX:
<
telerik:RadButton
ID
=
"testButton"
runat
=
"server"
Text
=
"Click Me!"
OnClientClicking
=
"ValidateJScript"
>
</
telerik:RadButton
>
<
telerik:RadNotification
ID
=
"notification"
runat
=
"server"
>
</
telerik:RadNotification
>
JS:
<script type=
"text/javascript"
>
function
ValidateJScript() {
var
notification = $find(
'<%=notification.ClientID %>'
);
var
message =
'Hello World'
;
notification.set_title(
"Error Notification"
);
notification.set_text(message);
notification.show();
alert(notification._text);
alert(notification._title);
}
</script>
I also advise that you upgrade to the latest version, as there have been some fixes on the RadNotification control and they may help you, as I am not sure exactly what and how you are using.
Hope this helps.
Regards,
Princy.
0

Tom
Top achievements
Rank 1
answered on 30 Oct 2012, 12:38 PM
thank you it is solved now.
one more question though, if i'm to show a newline using Jscript, the notification will NEVER show now! Any idea?
one more question though, if i'm to show a newline using Jscript, the notification will NEVER show now! Any idea?
var
message=
""
;
message =
"Hello \n"
;
message = message +
"World"
;
notification.set_text(message);
notification.show();
0
Hi Tom,
The most likely reason for your problems is a JavaScript error on the page. The original was due to the incorrectly attached handler to the RadButton and more information about that can be found in this blog post.
Regarding the new lines - the notification takes an HTML string, so the new line character is <br /> and the following snippet works fine with me:
Regards,
Marin Bratanov
the Telerik team
The most likely reason for your problems is a JavaScript error on the page. The original was due to the incorrectly attached handler to the RadButton and more information about that can be found in this blog post.
Regarding the new lines - the notification takes an HTML string, so the new line character is <br /> and the following snippet works fine with me:
<
script
type
=
"text/javascript"
>
function ValidateJScript()
{
var notification = $find('<%=notification.ClientID %>');
var message = 'Hello
<
br
/>
World';
notification.set_title("Error Notification");
notification.set_text(message);
notification.show();
}
</
script
>
<
telerik:RadButton
ID
=
"testButton"
runat
=
"server"
Text
=
"Click Me!"
AutoPostBack
=
"false"
OnClientClicking
=
"ValidateJScript"
>
</
telerik:RadButton
>
<
telerik:RadNotification
ID
=
"notification"
runat
=
"server"
Width
=
"200px"
Height
=
"100px"
>
</
telerik:RadNotification
>
Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Tom
Top achievements
Rank 1
answered on 31 Oct 2012, 12:46 PM
Thank you so much! This worked like a treat, but!
if i place the Jscript in a seperate file and i add that regularly to my page, the same problem occurs and my radnotification is never recognized. (but the document can find it: like if i write alert(notification.title) for example it displays it correctly in the alert, but "show" and all other methods of the notification won't work. any idea?
if i place the Jscript in a seperate file and i add that regularly to my page, the same problem occurs and my radnotification is never recognized. (but the document can find it: like if i write alert(notification.title) for example it displays it correctly in the alert, but "show" and all other methods of the notification won't work. any idea?
0
Hello Tom,
The way a reference to the notification is obtained includes server code blocks which cannot be used in external files, as they have to be parsed by the server. Thus, your code throws a JavaScript error because of the incorrect reference.
What I can advise is that you keep a function that will return this reference in the aspx page and call that from the external file instead of using directly $find() there.
Regards,
Marin Bratanov
the Telerik team
The way a reference to the notification is obtained includes server code blocks which cannot be used in external files, as they have to be parsed by the server. Thus, your code throws a JavaScript error because of the incorrect reference.
What I can advise is that you keep a function that will return this reference in the aspx page and call that from the external file instead of using directly $find() there.
Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

TechSystem
Top achievements
Rank 1
answered on 18 Apr 2018, 03:45 AM
trying to implementing https://demos.telerik.com/aspnet-ajax/notification/examples/sessiontimeout/defaultcs.aspx
but below line undefined please suggest
serverIDs({ notificationID: '<%= RadNotification1.ClientID %>' });
JavaScript runtime error: 'serverIDs' is undefined
Unable to get property 'get_value' of undefined or null reference