ASP.NET 4.0 Preview 6 and ScriptSharp

27 views
Skip to first unread message

mvbaffa

unread,
Nov 9, 2009, 5:11:10 AM11/9/09
to Scriptsharp
Hi,

I am working with ASP.NET 4.0 Preview 6 and I need to generate
Javascript for a specific scenario. Preview 6 has a Class called
Observer and many other new classes. The lastest version of
ScriptSharp uses an older version of Sys namespace that does not
support this version.

Using the annotations [IgnoreNamespace], [Imported] and
[GlobalMethods] I could create a class in Sys namespace called
Observer that allows me to generate javascript code for the Observer
Class. It is working Ok.

Now I have created an object that must be observed. As you know we
must use a methods like beginupdate to signal the start of the update
of an observable object, setvalue to change the object and end update
to finish. How can I do it the object is objecta I must generate
javascriopt to do the following thing:

objecta.beginupdate;
objecta.setvalue("property1", newvalue1);
objecta.setvalue("property2", newvalue2);
objecta.endupdate;

What could the best practice to use ASP.NET 4.0 Preview 6 with
ScriptSharp and make this and many other things work.

Thanks in advance

rekna

unread,
Nov 9, 2009, 6:52:50 AM11/9/09
to Scriptsharp
I am not familiar with ASP.NET 4.0 yet, so I don't know if this is
what you mean to do:

Create a stub class that has the definitions for the methods
[Imported]
[IgnoreNamespace]
public class Observable
{
[PreserveName]
public void beginupdate() {}
[PreserveName]
public void setvalue(string name, object value) {}
}

Then a temp variable and casting to force right type

Observable tmp = (Observable)(object)
objectTobeObserved; // ** serious hack **
tmp.beginupdate();
tmp.setvalue("test",10);

code generated :

var tmp = objectTobeObserved;
tmp.beginupdate();
tmp.setvalue('test', 10);

Another way, is making your objectToBeObserved a subclass of
Observable if that's possible.

mvbaffa

unread,
Nov 9, 2009, 7:18:48 AM11/9/09
to Scriptsharp
Hi Rekna,

I believe that could be the real best, and maybe the only solution. I
have posted in ASP.NET forum the same question and put a pointer to
this group trying to make people come here and post its questions.

Thansk you very much
Reply all
Reply to author
Forward
0 new messages