Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the method:

C#
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());
            }
        }


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

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 ?
 
Share this answer
 
Comments
Pavel Yermalovich 13-May-10 12:17pm    
In my case, there is "Help" LinkButton at the MasterPage. And I want to attach the handler to open page (Help.aspx) in new window or tab. Earliar I solved this issue by using shown above method. And now I don't know how to execute JavaScript at master. Give please a piece of advice how to modify my existing method or write new one.
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 ?
 
Share this answer
 
Comments
Pavel Yermalovich 13-May-10 12:40pm    
I just needed to attach to Help button the handler to onclick event for opening Help page in new tab or window. And first I thought to use written by me method for page. I have already understood to act another way. Just it :

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900