如何从 JavaScript 使用 Telerik RadConfirm

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11475652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 13:21:58  来源:igfitidea点击:

How to use Telerik RadConfirm from JavaScript

javascriptjquerytelerik

提问by vmg

How to use radconfirm from JavaScript? Functions radalert or radconfirm not defined. Could someone please show me the sample?

如何从 JavaScript 使用 radconfirm?函数 radalert 或 radconfirm 未定义。有人可以给我看样品吗?

for example when I call this function I get radalert is undefined:

例如,当我调用此函数时,我得到 radalert 未定义:

function testWnd() {
                  radalert("Confirm returned the following result: " + arg);
        }

回答by kashyapa

Please follow the below steps to achieve the radalert functionality from the client side:

请按照以下步骤从客户端实现 radalert 功能:



Step 1: Markup.

第 1 步:标记。



On your web page please include an instance of RadWindowManager. Without this radalert, radconfirm or radprompt wont work. This is the backbone of this feature. Here is the code snippet:

请在您的网页上包含一个 RadWindowManager 实例。如果没有这个 radalert,radconfirm 或 radprompt 将无法工作。这是此功能的支柱。这是代码片段:

<telerik:RadWindowManager ID="RadWindowManager1" 
                          runat="server" EnableShadow="true">
</telerik:RadWindowManager>

Next place a normal button and handle its onclick event. Here is the code snippet:

接下来放置一个普通按钮并处理其 onclick 事件。这是代码片段:

<button style="width: 150px;" 
        onclick="radalert('Radalert is called from the client!', 
                          330, 100,
                          'Client RadAlert', 
                          alertCallBackFn, imgUrl); return false;">
        radalert from client</button>

notice the callback for the radlalert named "alertCallBackFn". We will code that function in next section. Also note the use of the variable imgUrl variable. This defines the image to be used in the radalert. We will see what it does in the next section.

注意名为“alertCallBackFn”的 radlarert 的回调。我们将在下一节对该函数进行编码。还要注意变量 imgUrl 变量的使用。这定义了要在 radalert 中使用的图像。我们将在下一节中看到它的作用。



Step 2: Javscript

第 2 步:JavaScript



The radalert needs a image to be shown as part of the alert window. Declare a global variable by name "imgUrl" as below:

radalert 需要一个图像作为警报窗口的一部分显示。通过名称“imgUrl”声明一个全局变量,如下所示:

//use custom image in the alert box
var imgUrl = "http://www.telerik.com/favicon.ico"; 
//do not show any image in the alert box
imgUrl = ""; 
//uses the default image in the alert box
imgUrl = null; 

Then create the radalert call back function as below:

然后创建radalert回调函数如下:

 function alertCallBackFn(arg) {
            radalert("<strong>radalert</strong> returned the following result: <h3 style='color: #ff0000;'>" + arg + "</h3>", null, null, "Result");
        }

Now when you click on the radalert button, you will see the alert box being shown with your text.

现在,当您单击 radalert 按钮时,您将看到与您的文本一起显示的警报框。

Hope this was the solution you were looking for.

希望这是您正在寻找的解决方案。

Lohith (Tech Evangelist, Telerik India)

Lohith(技术布道师,Telerik India)

回答by Arbejdsgl?de

did you see this example http://demos.telerik.com/aspnet-ajax/window/examples/browserdialogboxes/defaultcs.aspxI am sure that you did't include some TELERIK components to you page

你看到这个例子了吗http://demos.telerik.com/aspnet-ajax/window/examples/browserdialogboxes/defaultcs.aspx我确定你没有在你的页面中包含一些 TELERIK 组件