How do I open another browser tab and display a page

0
0

I have a form displayed. User clicks a button, answers a question, and clicks OK. This should open a Wisej.Web.Page in a second browser tab.

This is the code executed in the OK_click event:

string url = “inspections/insptemplate?feename=permit”;

this.Eval($@”
var link = document.createElement(‘a’);
link.href = ‘{url}’;
link.target = ‘_blank’;
link.style.display = ‘none’;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
“);

but browser seems to be looking for html file?

How do I do this?

  • You must to post comments
0
0

Instead of your eval call, do Application.Navigate("link","_blank");
_blank tells it to open the page in a new tab.
For example, create a Wisej project with Page1 and Page2. Create a button with a click event and call this code in the click event:

Application.Navigate(Application.StartupUrl + "#page2", "_blank");

In Program.cs, add this to the Main function:
static void Main()
{
if (Application.Hash == "page2")
new Page2().Show();
else
new Page1().Show();

}

See attached sample.

Note: Another approach would be to attach to the HashChanged event. However, that only works if you’re not opening the page in a new tab. Opening a page in a new tab creates a new session.

  • Jean Vallee
    thanks! I spend some time on this today.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.