Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug HtmlPage.Window.Invoke does not appear to work in VB
11 replies. Latest Post by atkinart on November 28, 2008.
(0)
GeordieJ...
Member
102 points
61 Posts
05-05-2008 6:59 AM |
i am thinking there is a problem with the HtmlPage.Window.Invoke in VB
what works in C#, gets the following
An exception of type 'System.InvalidOperationException' occurred in System.Windows.Browser.dll but was not handled in user code
Additional information: [ScriptObject_InvokeFailed]Arguments:Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=8.0.30226.2&File=System.Windows.Browser.dll&Key=ScriptObject_InvokeFailed
mchlsync
Star
14606 points
2,730 Posts
05-05-2008 9:43 AM |
Hello,
I just tested it. It's working for me.
Example:
Imports System.Windows.BrowserPartial Public Class Page Inherits UserControl Public Sub New() InitializeComponent() AddHandler MouseLeftButtonDown, AddressOf Click End Sub Public Sub Click(ByVal sender As Object, ByVal e As MouseButtonEventArgs) HtmlPage.Window.Eval("window.close();") End SubEnd Class
Hope it helps.
05-05-2008 11:48 AM |
Agreed - the eval works - the invoke, which goes back to the Javascript isn't
05-05-2008 12:05 PM |
GeordieJenner:Agreed - the eval works - the invoke, which goes back to the Javascript isn't
Can you show me your code? It's working fine for me.
SilverlightApplication1VBTestPage.aspx
<%@ Page Language="VB" AutoEventWireup="true" %><%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;"><head runat="server"> <title>Test Page For SilverlightApplication1VB</title> <script type="text/javascript"> function foo(){ alert("Foo() method is invoked."); } </script></head><body style="height:100%;margin:0;"> <form id="form1" runat="server" style="height:100%;"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <div style="height:100%;"> <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/SilverlightApplication1VB.xap" Version="2.0" Width="100%" Height="100%" /> </div> </form></body></html>
Page.xaml.vb
Imports System.Windows.BrowserPartial Public Class Page Inherits UserControl Public Sub New() InitializeComponent() AddHandler MouseLeftButtonDown, AddressOf Click End Sub Public Sub Click(ByVal sender As Object, ByVal e As MouseButtonEventArgs) ''//HtmlPage.Window.Eval("window.close();") HtmlPage.Window.Invoke("foo", Nothing) End SubEnd Class
05-05-2008 12:31 PM |
*****VB*****
**** HTML ****
window.close();
}
{
alert(1);
05-05-2008 7:48 PM |
It works for me. I tested with both HTML page or aspx page.
SilverlightApplication1VBTestPage.aspx (ASPX version)
<%@ Page Language="VB" AutoEventWireup="true" %><%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;"><head runat="server"> <title>Test Page For SilverlightApplication1VB</title> <script type="text/javascript"> function onCloseWindow(){ window.close(); } </script></head><body style="height:100%;margin:0;"> <form id="form1" runat="server" style="height:100%;"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <div style="height:100%;"> <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/SilverlightApplication1VB.xap" Version="2.0" Width="100%" Height="100%" /> </div> </form></body></html>
SilverlightApplication1VBTestPage.html (HTML Version)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><!-- saved from url=(0014)about:internet --><head> <title>Silverlight Project Test Page </title> <style type="text/css"> html, body { height: 100%; overflow: auto; } body { padding: 0; margin: 0; } #silverlightControlHost { height: 100%; } </style> <script type="text/javascript"> function onSilverlightError(sender, args) { if (args.errorType == "InitializeError") { var errorDiv = document.getElementById("errorLocation"); if (errorDiv != null) errorDiv.innerHTML = args.errorType + "- " + args.errorMessage; } } function onCloseWindow(){ window.close(); } </script></head><body> <!-- Runtime errors from Silverlight will be displayed here. This will contain debugging information and should be removed or hidden when debugging is completed --> <div id='errorLocation' style="font-size: small;color: Gray;"></div> <div id="silverlightControlHost"> <object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%"> <param name="source" value="ClientBin/SilverlightApplication1VB.xap"/> <param name="onerror" value="onSilverlightError" /> <param name="background" value="white" /> <a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> </a> </object> <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe> </div></body></html>
Imports System.Windows.BrowserPartial Public Class Page Inherits UserControl Public Sub New() InitializeComponent() AddHandler MouseLeftButtonDown, AddressOf Click End Sub Public Sub Click(ByVal sender As Object, ByVal e As MouseButtonEventArgs) HtmlPage.Window.Invoke("onCloseWindow", Nothing) End SubEnd Class
05-05-2008 9:16 PM |
it works in aspx, i was only trying it in Html, which it still does not - thank you - but still no way to get rid of the dialog box :O(
05-05-2008 9:42 PM |
GeordieJenner:it works in aspx, i was only trying it in Html, which it still does not -
I showed you both aspx and HTML in my previous post. "SilverlightApplication1VBTestPage.html (HTML Version) "
GeordieJenner:but still no way to get rid of the dialog box :O(
IMHO, I never like that idea... In fact, it is IE-only solution. I used to open a lot of tabs in my browsers and I never want any website to close my browser... I'm not sure why you want to do that.
05-06-2008 7:30 AM |
this is an application with passwords - if it fails, say 3 times, i want them kicked out
05-07-2008 3:04 AM |
GeordieJenner:this is an application with passwords - if it fails, say 3 times, i want them kicked out
Okay. But we are discussing about the fact whether HtmlPage.Window.Invoke is working fine in VB or not.
Have you tested my code in my previous message? Is it working for you?
05-07-2008 7:37 AM |
in aspx, not html, but yes, thank you
atkinart
2 points
1 Posts
11-28-2008 4:05 AM |
Hello, this method work in IE, but I use FireFox 3 and this method do not work. Please prompt me how I can solve this problem. Excuse my English :)