Access silverlight control name in Javascript
I have a text box in which i enter some random text. I have a java script function named FormatText(control-name,command). Inside this java script function i need to access the text box's text property so that the text can be formatted depending on the command that is passed( eg bold,italic,underline). Hence i needed to know whether there i开发者_如何学编程s any way to access a control's name through javascript
I don't think you can do it directly, but you can access JavaScript from within Silverlight, so you can do something like this:
using System.Web.Browser;
HtmlPage.Window.CreateInstance("myFunction", new string[] { textBox.Name });
This will invoke myFunction
with the name of the TextBox as it's parameter.
Source
So when you initialise the control you could call this to get the name into your JavaScript.
精彩评论