开发者

Access silverlight control name in Javascript

开发者 https://www.devze.com 2023-02-25 18:46 出处:网络
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 proper

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消