Slow and steady Silverlight (27)

Source: Internet
Author: User
Tags datetime silverlight

Slow-moving Silverlight (27)-2.0 Web pages are scriptable, interacting with the DOM, interacting with JavaScript

Introduced

Silverlight 2.0 uses C # to develop scriptable code, the interaction between Silverlight and the DOM of the host home page, and the interaction between Silverlight and the host page's JavaScript

ScriptableMemberAttribute-attributes, methods, events that need to be scripted to mark this

Htmlpage.registerscriptableobject-Registers a scriptable object with the client

HtmlElement-HTML element representing the Document Object Model (DOM) of a Web page

HtmlWindow-a managed representation of the Silverlight end of the Window object that provides JavaScript

Online Demo

Http://www.cnblogs.com/webabcd/archive/2008/10/09/1307486.html

Example

1. Silverlight Support for scripting

Scriptable.cs

Using System;
Using System.Net;
Using System.Windows;
Using System.Windows.Controls;
Using System.Windows.Documents;
Using System.Windows.Ink;
Using System.Windows.Input;
Using System.Windows.Media;
Using System.Windows.Media.Animation;
Using System.Windows.Shapes;

Using System.Windows.Browser;

Namespace Silverlight20.webpage
{
/**//*
* Scripted classes must be public
* Attributes, methods, events that need to be scripted are marked as [Scriptablemember]
* If a class is marked as [Scriptabletype], it means that its properties, methods, and events are ScriptableMemberAttribute
*/

/**////<summary>
Class for demonstrating scripting
</summary>
[Scriptabletype]
public class scriptable
{
/**////<summary>
Current service-side time
</summary>
[Scriptablemember]
Public DateTime currenttime {get; set;}

/**////<summary>
Hello method
</summary>
<param name= "name" > Name </param>
<returns></returns>
[Scriptablemember]
public string Hello (string name)
{
return string. Format ("Hello: {0}", name);
}

/**////<summary>
Start Event
</summary>
[Scriptablemember]
public event eventhandler<starteventargs> Start;

/**////<summary>
The method invoked to trigger the start event
</summary>
<param name= "DT" ></param>
public void OnStart (DateTime dt)
{
if (Start!= null)
{
Start (This, new Starteventargs ()
{
currenttime = DT
});
}
}

}

/**////<summary>
EventArgs of the Start event
</summary>
public class Starteventargs:eventargs
{
/**////<summary>
Current service-side time
</summary>
[Scriptablemember]
Public DateTime currenttime {get; set;}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.