Another resource you should consider using is the AI search feature on our website: https://wisej.com/blog/your-wisej-net-questions-answered-powered-by-ai/
For example, if I search “How to prevent the user from closing the browser” I get this result:
You cannot fully prevent a user from closing their browser or tab, but you can warn them before they leave the page using the browser’s built-in “beforeunload” event.
To show a warning when a user tries to close the tab or browser:
window.addEventListener('beforeunload', function (e) { e.preventDefault(); e.returnValue = ''; });
This triggers a confirmation dialog when the user tries to close the tab, refresh, or navigate away. Modern browsers do not allow you to customize the dialog text for security reasons. Users can still choose to leave, so this only acts as a warning, not a true prevention.There is no way to completely block a user from closing their browser or tab, as this would be a security and usability risk. Use the “beforeunload” event to warn users, but always design your application to handle unexpected exits gracefully.
Here you should use the Application.EnableUnloadConfirmation, see documentation here: https://docs.wisej.com/api/v3.5/wisej.web/general/application#enableunloadconfirmation Simply set Application.EnableUnloadConfirmation = true;
See also this forum thread: https://wisej.com/support/question/how-can-i-implement-a-notification-or-warning-message-in-wisej-when-a-user-attempts-to-close-the-browser-or-tab
Yes. You’ll need to set the BoldedDates property to the dates that you want to set the backcolor for. Then modify the theme to set the back color.
See my answer here, which includes a a sample with the modified theme. https://wisej.com/support/question/datetimepicker
Hi,
I’m back with a compilable test case that shows the issue, including the URL I’ve been testing.
The behavior is exactly as I previously described:
01. If you load the tree view with all elements, the JavaScript does not execute at all.
02. If you load it with only 4 elements, the JavaScript executes and displays a message that nothing was found (which is not the issue we’re discussing).
Execute the two buttons in different sessions, not one after another in one session.
Please find source code attached. It is based on NET 4.8
Kind regards!
Hi there,
I tried to reproduce the issue exactly like you stated, and I couldn’t reproduce.
Furthermore, having a TreeView with more than 4 nodes works, there’s no relation as to why having a TreeView with more than 4 nodes would fail evaluating javascript in the WebBrowser component.
At this point, we’re trying to guess what you’re trying to accomplish and it’s beyond the scope of free Wisej.NET support, please verify the javascript you’re trying to execute and make sure everything is escaped correctly.
The only way for us to verify this is to have a compilable, ready-to-run sample that demonstrates the issue reported.
Best Regards,
Alaa
Hi,
I’m coming back with a solution to the problem, whose cause and fix turned out to be utterly absurd.
If a SplitContainer contains a TreeView and a Wisej.Web.WebBrowser, and the TreeView has more than 4 nodes, then Wisej.Web.WebBrowser.Eval(js)
does not execute.
But if the number of nodes is 4 or fewer, the JS does execute.
This bizarre bug makes it impossible to implement an e-book scenario with a browser and a tree view containing more than 4 topics — which is, to put it mildly, EXTREMELY ANNOYING.
Please find images attached.
Perfect 🙂
Hi Mirko,
see here:
https://docs.wisej.com/api/wisej.web/general/application#runtimemode
Best regards
Frank
It’s not supported.
The closest thing is, you can use a MonthCalendar and set the BoldedDates. You can then theme the background color of the Bolded Dates.
The theme would look like this:
“datechooser”: {
“components”: {
“day”: {
“states”: {
“bolded”: {
“styles”: {
“css”: “{\”font-weight\”:\”900 !important\”, \”overflow\”:\”visible !important\”,\”display\”:\”flex\”,\”alignItems\”:\”center\”,\”justifyContent\”:\”center\”}”,
“backgroundColor”: “green”
},
See attached test case with a modified version of the bootstrap theme.
You could also consider using FullCalendar for something like this.
Hi mgmst,
we need a compilable test case that shows the issue including the URL that you have been testing.
Otherwise we cannot help any further.
Best regards
Frank
When it is in the test application (please find attached), I at least receive “Nothing found” message, which points that JS works.
When it is in a my control for books’ content loading- JS not works at all! Why so? Please advice.
Public Class C_Books_Container
Inherits Panel
Private ОWebBrowser As New CUtils.CInterfaceIni.CInterface.C_Wisej_Web_WebBrowser
Public WithEvents OTV As New CUtils.CInterfaceIni.CInterface.CTreeViewS.CTreeView.CTreeView_basic_01(Guid.NewGuid)
Private OSplitContainer As New SplitContainer
Public Sub New(INOStrURLText As String, INOSTRDelimiter As String, INOSTRDelimiter_Internal As String)
ОWebBrowser.Dock = DockStyle.Fill
OTV.Dock = DockStyle.Fill
With OSplitContainer
.Dock = DockStyle.Fill
.Panel1.Controls.Add(OTV)
.Panel2.Controls.Add(ОWebBrowser)
End With
ОWebBrowser.Url = New Uri(INOStrURLText)
Dim OStringPageContent As String = GetTextFromUrl(INOStrURLText)
F_TableОfContents_Get(OTV, OStringPageContent, INOSTRDelimiter, INOSTRDelimiter_Internal)
Me.Dock = DockStyle.Fill
Me.Controls.Add(OSplitContainer)
End Sub
Private Sub OTV_NodeMouseClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles OTV.NodeMouseClick
Dim searchText = “5”
Dim js As String =
”
var found = false;
var elements = document.getElementsByTagName(‘*’);
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerText && elements[i].innerText.includes(‘” & searchText.Replace(“”””, “\”””) & “‘)) {
elements[i].scrollIntoView({behavior: ‘smooth’, block: ‘center’});
elements[i].style.backgroundColor = ‘yellow’;
found = true;
break;
}
}
if (!found) {
alert(‘Nothing found.’);
}
”
ОWebBrowser.Eval(js)
End Sub
End Class
Javascript is executed by the browser. So I used google and found why your “code” doesn’t work.
https://stackoverflow.com/ questions/3999101 /get-iframes-document-from-javascript-in- main- document
Nothing at all, complete silence and darkness.
Hi,
“does not work” means what? Do you get an error in the console?
We need a test case with a clear indication of expected result to check this.
Best regards
Frank
Ciao Gabriele,
I cannot reproduce in 3.5.21 with my Pixel 7 and Nexus6P emulators. What type of device are you using?
Grazie,
Levie
Thanks Alaa for your attention to this. The solution does work, however, at first startup I get an exception that cannot be caught: “Cannot read properties of undefined (reading ‘option’)”. This occurs in your project as well as in mine. If I set this option after the first appearance, then it does hide the weekend days.
Hi Chris,
I have attached a sample that showcases the required feature.
HTH,
Alaa
Hi Roni,
that’s a website, it’s build with Wordpress + Plugins.
Wisej.NET is for enterprise web applications. Not really related.
Best regards
Frank
You can pass the parameters like this:
Application.Navigate("?mypar=1");
You can then get the values like so:
AlertBox.Show(Application.QueryString.ToString());
returns: mypar=1
And this returns just the value:
string[] values = Application.QueryString.GetValues(0);
AlertBox.Show(values[0]);
returns: 1
See attached sample
You might also find these forum threads to be helpful:
https://wisej.com/support/question/url-parameters
https://wisej.com/support/question/url-arguments
John-
Your code does work. See attached test case. I am able to open the Project folder and view the file inside.
Julie