Monday 26 December 2011

open new window in asp.net website

How to open new window in asp.net website

Use this code to open new window

 const string windowName = "";
            //params for a window

            const string windowParams = "height=760,width=760,status=yes,toolbar=no,menubar=no,location=no,resizable,name=Notes";
 private void OpenNewWindow(string url, string windowName, string windowParams)
        {
            if (url == null)
                throw new ArgumentNullException("url");
            if (windowName == null)
                windowName = "";
            if (windowParams == null)
                windowParams = "";
            string scriptCode =
                string.Format(
                    "<script>window.open('{0}','{1}','{2}');</script>",
                    url, windowName, windowParams);
            //write the script out to HTTP Response stream
            Response.Write(scriptCode);
        }
after pasting this code in Your webform  call this method  to open new window
like  below


  OpenNewWindow(url, windowName, windowParams);

No comments:

Post a Comment