Beispiel #1
0
 /*
  * The NewWindow3 object is triggered whenever a page tries to open a new window, which by default opens in a new IE window.
  * NewWindow3 has property BStrURL which is the location to be loaded in the new window. If you cancel the action, you can
  * capture the location and reroute or choose a different set of actions.
  */
 private void webBrowser1_NewWindow3(object sender, NewWindow3EventArgs e)
 {
     //MessageBox.Show("We going somewhere", "Where we going?");
     //MessageBox.Show(e.BStrURL, "Going here");
     if (e.BStrURL.Contains("authoring"))
     {
         e.Cancel = true;
         MessageBox.Show(e.BStrURL, "Web Authoring Triggered");
         edit_mode = true;
         webBrowser1.Navigate(e.BStrURL);
     }
     // This one needs the window to atually show up, maybe place in its own separate tab? But will that maintain session??
     else if (e.BStrURL.Contains("viewData"))
     {
         e.Cancel = true;
         webBrowser1.Navigate(e.BStrURL);
     }
     // For all of these, redirecting the URL back into current window causes the download dialog to appear successfully
     else if (
         e.BStrURL.Contains("tempfile") ||
         e.BStrURL.Contains("crosstab") ||
         e.BStrURL.Contains("csv=true")
         )
     {
         e.Cancel = true;
         webBrowser1.Navigate(e.BStrURL);
     }
 }
        protected void OnNewWindow3(ref object ppDisp, ref bool cancel, long dwFlags, string bstrUrlContext, string bstrUrl)
        {
            EventHandler <NewWindow3EventArgs> h = NewWindow3;
            NewWindow3EventArgs args             = new NewWindow3EventArgs(ref ppDisp, ref cancel, dwFlags, bstrUrlContext, bstrUrl);

            if (null != h)
            {
                h(this, args);
            }
            //Pass the cancellation chosen back out to the events
            //Pass the ppDisp chosen back out to the events
            cancel         = args.Cancel;
            ppDisp         = args.PPDisp;
            bstrUrlContext = args.BStrURLContext;
            bstrUrl        = args.BStrURL;
        }
 protected void OnNewWindow3(ref object ppDisp, ref bool cancel, long dwFlags, string bstrUrlContext, string bstrUrl)
 {
     EventHandler<NewWindow3EventArgs> h = NewWindow3;
     NewWindow3EventArgs args = new NewWindow3EventArgs(ref ppDisp, ref cancel, dwFlags, bstrUrlContext, bstrUrl );
     if (null != h)
     {
         h(this, args);
     }
     //Pass the cancellation chosen back out to the events
     //Pass the ppDisp chosen back out to the events
     cancel = args.Cancel;
     ppDisp = args.PPDisp;
     bstrUrlContext = args.BStrURLContext;
     bstrUrl = args.BStrURL;
 }
        /*
         * The NewWindow3 object is triggered whenever a page tries to open a new window, which by default opens in a new IE window.
         * NewWindow3 has property BStrURL which is the location to be loaded in the new window. If you cancel the action, you can
         * capture the location and reroute or choose a different set of actions.
         */
        private void webBrowser1_NewWindow3(object sender, NewWindow3EventArgs e)
        {
            //MessageBox.Show("We going somewhere", "Where we going?");
            //MessageBox.Show(e.BStrURL, "Going here");
            if (e.BStrURL.Contains("authoring")) {
                e.Cancel = true;
                MessageBox.Show(e.BStrURL, "Web Authoring Triggered");
                edit_mode = true;
                webBrowser1.Navigate(e.BStrURL);

            }
            // This one needs the window to atually show up, maybe place in its own separate tab? But will that maintain session??
            else if (e.BStrURL.Contains("viewData"))
            {
                e.Cancel = true;
                webBrowser1.Navigate(e.BStrURL);
            }
            // For all of these, redirecting the URL back into current window causes the download dialog to appear successfully
            else if (
                        e.BStrURL.Contains("tempfile") ||
                        e.BStrURL.Contains("crosstab") ||
                        e.BStrURL.Contains("csv=true")
                    )
            {
                e.Cancel = true;
                webBrowser1.Navigate(e.BStrURL);
            }
        }