From: http://social.msdn.microsoft.com/Forums/zh-TW/1511/thread/2142d892-be3a-4726-9df4-df68dae1d76d
You can refer to the following practices:
1. In SL:
Imports system. Windows. Browser
<Scriptabletype ()> _
Partial public class page
Inherits usercontrol
Public sub new ()
Initializecomponent ()
Htmlpage. registerscriptableobject ("test", me)
End sub
'This is Scriptable Function
<Scriptablemember ()> _
Public Function XXX () as string
Return txt1.text
End Function
End Class
In aspx:
<Script language = "JavaScript" type = "text/JavaScript">
Function getparamfromsl (){
VaR Silverlight = Document. getelementbyid ("SL ");
If (Silverlight ){
VaR rvalue = Silverlight. content. Test. XXX ();
Alert (Rvalue );
}
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: scriptmanager id = "scriptmanager1" runat = "server"
Enablescriptglobalization = "true" enablepagemethods = "true">
</ASP: scriptmanager>
<Div style = "height: 100%;">
<Asp: Silverlight id = "SL" runat = "server" Source = "~ /Clientbin/silverlightapplication1.xap"
Minimumversion = "2.0.31005.0" width = "100%" Height = "100%"/>
<Asp: button id = "button1" runat = "server" onclientclick = "javascript: getparamfromsl (); Return false ;"
TEXT = "button"/>
</Div>
</Div>
</Form>
</Body>
Thank you for choosing OK ..