如何使用ScriptManager的类文件? [英] How to use ScriptManager in class file?

查看:144
本文介绍了如何使用ScriptManager的类文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示使用page.clientScript警报信息的常用方法。但后来我加入更新面板。现在,这片code的不工作。所以,我需要调用有ScriptManager的,但我得到了一些错误信息,这是访问那里。
下面是我common.cs文件ShowMessage方法

I Have a common method that displays alert message using page.clientScript. But later on i added update panel. Now this piece of code is not working. So I need to call there scriptmanager, but i get some error message that it is accessible there. Below is my ShowMessage method of common.cs file

 private static void ShowMessage(Page currentPage, string message)
        {
            var sb = new StringBuilder();
            sb.Append("alert('");
            sb.Append(message);
            sb.Append("');");
            currentPage.ClientScript.RegisterClientScriptBlock(typeof(Common), "showalert", sb.ToString(), true);
        }

那么,如何使用此方法更新面板下

So how do I use this method under update panel

推荐答案

请使用:的 ScriptManager.RegisterClientScriptBlock方法

ScriptManager.RegisterClientScriptBlock(
            this,
            typeof(Page),
            "TScript",
            script,
            true);

这篇关于如何使用ScriptManager的类文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆