简体   繁体   English

如何从ASP.Net主页中的外部JavaScript调用Telerik radalert

[英]How to call Telerik radalert from external JavaScript in ASP.Net master page

I need to show an message using radalert in all the content pages associated with the master page. 我需要在与母版页关联的所有内容页中使用radalert显示一条消息。

I am not able to add the JavaScript code to the master page, so i had to add the below specified code in external JavaScript file. 我无法将JavaScript代码添加到母版页,因此必须在外部JavaScript文件中添加以下指定的代码。

When the below specified code is added to the content page, it displays the message before session expires. 将以下指定的代码添加到内容页面后,它将在会话过期之前显示该消息。 JavaScript code: JavaScript代码:

 var sessionTimeoutWarning = "1";
 var sessionTimeout = "2";
 var timeOnPageLoad = new Date();

setTimeout('RedirectToWelcomePage()', parseInt(sessionTimeout) * 60 * 1000);

 function RedirectToWelcomePage() {
        var message = "Session expired. Redirecting to Login page";
        radalert(message, 320, 100, "Information Message");
        window.location = "Login.aspx"
    }   

But when the code is added to the external javascipt file so that it can be implemented in all the pages dependent on the master page it gives "Unable to get property 'radalert' of undefined or null reference" error at the radalert 但是,当将代码添加到外部javascipt文件中以便可以在依赖于母版页的所有页面中实施代码时,在radalert处会出现“无法获取未定义或空引用的属性'radalert'”错误

If you are accessing radcontrols from external javascript. 如果您要从外部javascript访问radcontrols。 You should be aware of parameters for that function.. 您应该知道该函数的参数。

For example : 例如 :

function open()
{
window.open("Hello World", 320, 100, "Information Message");
}

The above script is not as same for Radcontrols. 上面的脚本与Radcontrols不同。 You need to add parameters 您需要添加参数

function open(sender, args)
{
radalert("Hello World", 320, 100, "Information Message");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从ASP.NET 5 WebAPI调用JavaScript页面上的函数 - How to call function on javascript page from ASP.NET 5 WebAPI 如何正确引用asp.net主页中的javascript文件? - How to properly reference javascript files in to asp.net master page? 如何在asp.net中修复Javascript计时器(母版页概念) - How to fix Javascript Timer In asp.net(Master Page concept) 如何在母版页弹出窗口的向导中从User Control中获取ControlToValidate ID-javascript asp.net验证 - How to get ControlToValidate ID from User Control in a wizard in a popup in a master page - javascript asp.net validation 来自 asp.net C# 页面的外部 javascript 文件 - external javascript file from asp.net C# page 从aspx.cs调用ASP.NET母版页(.Master)函数 - From aspx.cs call ASP.NET Master Page (.Master) function ASP.NET母版页上的Javascript不在子目录的内容页上运行 - Javascript on ASP.NET Master page not running on content page in subdirectory 通过使用母版页的表单在asp.net中调用javascript函数 - call javascript function in asp.net through a form using master page 从主文件到外部javascript库获取asp.net会话变量 - Get asp.net session variables from master file to external javascript library 从ASP.Net用户控制事件调用页面上的javascript - Call javascript on page from ASP.Net User Control Event
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM