0

I am looking for a way to open my silverlight application from my web application using javascript. I will also need to pass a string to the silverlight application during this process. The code below will currently open the silverlight application for me. I need to know how to do this while passing in the string value to silverlight.

$(function () {
$('.cell').on('focus', 'textarea', function () {
    var inputValue = $(this).val();     
    window.open('/TestPage.aspx');
});

});

Note: I have searched everywhere for the answer to this and cant seem to find a decent solution. All of the demos I've found are incomplete or do not function as expected.

416E64726577
  • 2,214
  • 2
  • 23
  • 47
nsmanners
  • 33
  • 1
  • 6

1 Answers1

0

You could pass it in the query string:

window.open('/TestPage.aspx?input=' + inputValue);

Retrieve it in Silverlight using HtmlDocument.QueryString:

string inputValue = null;
if (HtmlDocument.QueryString.ContainsKey("input"))
    inputValue = HtmlDocument.QueryString["input"];
McGarnagle
  • 101,349
  • 31
  • 229
  • 260
  • Thanks for the response! I meant to mention that a query string is not an option. I am passing an rtf string which has too many symbols. – nsmanners Oct 11 '13 at 20:50
  • @nsmanners are you sure? You can always url-encode the string, and you're allowed up to 2,000 characters: http://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string – McGarnagle Oct 11 '13 at 20:54
  • @nsmanners if it's too long, then you could always use an Ajax post instead. – McGarnagle Oct 11 '13 at 20:55
  • I am afraid several of the rtf strings will have well over 2000 characters. Would you happen to have an example of how to open a silverlight window while utilizing ajax? – nsmanners Oct 11 '13 at 21:05
  • @nsmanners my mistake, I meant use a regular form post, not an Ajax one -- send the string as an HTTP Post parameter to "TestPage.aspx", where you retrieve it using `Request.Params`, and add it to the Silverlight `initParams`. – McGarnagle Oct 11 '13 at 21:23