Asp.net gets the value in Silverlight)

Source: Internet
Author: User
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 ..

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.