如何在MasterPage上调用Javascript [英] How to call Javascript at MasterPage

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

问题描述

我有方法:

I have the method:

public static void OpenPageInNewWindow(Page page, string pageUrl)
        {
            Type t=page.GetType();
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language='javascript'>");
            sb.Append("window.open('" + pageUrl + "');");
            sb.Append("</script>");
            if (!page.ClientScript.IsClientScriptBlockRegistered(t,"newwindow"))
            {
                page.ClientScript.RegisterClientScriptBlock(t,"newwindow",sb.ToString());
            }
        }



我想在MasterPage上使用它.



I want to use it at MasterPage. How to change it or rewrite?

推荐答案

是什么让您认为自己必须要做的?我的意思是,页面的每次刷新也会打开另一个窗口,这似乎很奇怪,但是,如果这是您想要的,为什么还要在母版页中对其进行更改?
What makes you think you''d have to ? I mean, it seems odd that every refresh of your page would open another window also, but, if that''s what you want, why would you change it in a master page ?


首先,不要按答案"来发布非答案.编辑您的问题或使用评论按钮.其次,我重复一遍,就浏览器而言,您的母版页不存在",因此您需要解释为什么这是您认为该代码将无法正常工作的原因.实际的问题是什么?
First of all, don''t push ''answer'' to post a non answer. Edit your question or use the comment buttons. Secondly, I repeat, your master page does not *exist* so far as the browser is concerned, so you need to explain why it is that you think this code will not just work. What is the actual issue ?


这篇关于如何在MasterPage上调用Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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