Reputation: 11
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 is any way to access a control's name through javascript
Upvotes: 0
Views: 331
Reputation: 137168
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.
So when you initialise the control you could call this to get the name into your JavaScript.
Upvotes: 1