xkrja wrote:
I'm trying to call javascript from IronPython (via Silverlight 2) but I can'
get it to work properly. I looked at this example:
http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10
http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10
It's explained very clearly but when I try to run my code I get a System
Error:
SystemError: Object reference not set to an instance of an object.
I just inserted the lines of code found on the example page in my IronPyton
code:
event = ScriptableEvent()
# This must also be registered
HtmlPage.RegisterScriptableObject("event", event)
args = ScriptableEventArgs()
args.val = 'some string'
event.OnEvent(args) #This gives me a System Error
I create a C# .dll as explained in the example and add a reference to it.
The source is below:
using System;
using System.Windows.Browser;
namespace Scriptable
{
[ScriptableTypeAttribute]
public class ScriptableForString
{
[ScriptableMemberAttribute]
public string method(string value)
{ return this._method(value); }
public virtual string _method(string value)
{ return "override me"; }
}
[ScriptableType]
public class ScriptableEvent
{
[ScriptableMember]
public event EventHandler Event;
public virtual void OnEvent(ScriptableEventArgs e)
{
Event(this, e);
}
}
[ScriptableTypeAttribute]
public class ScriptableEventArgs : EventArgs
{
private string _val;
[ScriptableMemberAttribute]
public string val
{
get { return _val; }
set { _val = value; }
}
}
}
Can anyone explain what I'm doing wrong?
Thanks for any help!
Hmmm... do you have any Javascript hooking up to the event? If you
don't, try hooking up to it and see if it makes any difference.
The same code works for me. :-)
Michael
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com