Webpage in dashboard

Are you calling the SetupBrowser() method every time you’re trying to change the displayed page? That could definitely be part of the problem. The WebBrowser control only needs to be instantiated once (in the class), initialized once (usually in InitializeCustomCode()), and then subsequent navigation calls are just wbSite.Navigate() on some sort of event. Go ahead and remove the wbSite = new WebBrowser() line from the SetupBrowser() method. The web browser is dynamic and will start loading the new site immediately without having to clear anything out - just like typing in a new URL and pressing Enter in an external browser.

What @Banderson said is spot on. You’ll need to identify an event that correlates to when the number changes and then call wbSite.Navigate(“http://envisionpp/test/callLogViewer.asp?custnum=” + epiTextCustNumReference2.Text) with the new customer number. Finding that event can sometimes be a frustrating process of trial-and-error with MessageBoxes, but you do get there eventually.

Thanks for this code, I used it successfully in my code with a variable URL. However, is it possible to add a toolbar to this so I can use the functions goBack or goForward or refresh?

I’m not sure what I should change to include some buttons there:

EDIT:
I added this but not sure how to add a toolbar now:
browserDisplay.Dock = System.Windows.Forms.DockStyle.Bottom; // it was ‘Fill’ before
browserDisplay.Location = new System.Drawing.Point(0, 40);

Glad to see you’ve got the placement figured out. I’ve never needed to add a toolbar, but you should be able to put an EpiButton control in that space and trigger the browser’s GoBack() or GoForward() method on a click event.

Yep, I figured it out too, surprisingly easy! I added this code:

ToolStrip mainToolBar = new ToolStrip();  
		mainToolBar.Size = new System.Drawing.Size(400, 40);
		//create previous button
		ToolStripButton buttonPrevious = new ToolStripButton();
		buttonPrevious.Text="Previous";
		buttonPrevious.Click += new System.EventHandler(buttonPrevious_Click);
		//create forward button
		ToolStripButton buttonForward = new ToolStripButton();  
		buttonForward.Text = "Forward";
		buttonForward.Click += new System.EventHandler(buttonForward_Click);
		//create refresh button
		ToolStripButton buttonRefresh = new ToolStripButton();  
		buttonRefresh.Text = "Refresh";
		buttonRefresh.Click += new System.EventHandler(buttonRefresh_Click);
		// add buttons to toolbar
		mainToolBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            buttonPrevious,
            buttonForward,
			buttonRefresh
		});

Now, I just need to add the epicor icons (refresh icon) on my buttons, don’t know how to find them ! :wink:

1 Like

I did get this working. Does anyone know how I would trigger an event on the browser close. I have this so far

//Launch Epicor URL - Any Area
	private void LaunchURL(string url, string title = "", int padding = 65)
	{
	Ice.Lib.Customization.CustomWebBrowserDialog uiWebBrowser = new Ice.Lib.Customization.CustomWebBrowserDialog();
	Ice.Lib.Framework.EpiBaseForm f = (Ice.Lib.Framework.EpiBaseForm)csm.PersonalizeCustomizeManager.TopControl.FindForm();
   uiWebBrowser.Width = f.Width - padding;
   uiWebBrowser.Height = f.Height - padding;
   uiWebBrowser.Text = title;
   uiWebBrowser.HomeURL = url;
   uiWebBrowser.StartPosition = FormStartPosition.CenterScreen; // If you don't center you can use .Top and .Left
   uiWebBrowser.Show();
   uiWebBrowser.OnRefresh(); // Loads URL
//	if (uiWebBrowser.Close)
//	{
//	RefreshAfterClose();
//}
//	
//}
//
////Order - Refresh After Close
//private void RefreshAfterClose()
//{
//MessageBox.Show("Window Closed");
//}

I’m sure there’s a better way to code this but this is how I got something working.

I didn’t find an event handler for the CustomWebBrowserDialog, but there’s the windows form handler FormClosed.

Try this:

    private void LaunchURL(string url, string title = "", int padding = 65)
    {
        Ice.Lib.Customization.CustomWebBrowserDialog uiWebBrowser = new Ice.Lib.Customization.CustomWebBrowserDialog();
        Ice.Lib.Framework.EpiBaseForm f = (Ice.Lib.Framework.EpiBaseForm)csm.PersonalizeCustomizeManager.TopControl.FindForm();
        uiWebBrowser.Width = f.Width - padding;
        uiWebBrowser.Height = f.Height - padding;
        uiWebBrowser.Text = title;
        uiWebBrowser.HomeURL = url;
        uiWebBrowser.StartPosition = FormStartPosition.CenterScreen; // If you don't center you can use .Top and .Left
        uiWebBrowser.Show();
        uiWebBrowser.OnRefresh(); // Loads URL

        // This is what probably should be moved somewhere else.
        uiWebBrowser.FormClosed += UiWebBrowser_FormClosed;
    }

    private void UiWebBrowser_FormClosed(object sender, FormClosedEventArgs e)
    {
        MessageBox.Show("web browser closed");
    }

Hello, just wondering how did you make a parameter pass and feed the URL with that value.

Thanks