javascript - Embedding a JS file in Silverlight Class Library -


i trying create silverlight class library needs call few javascript methods. have put these methods in single .js file , have added project. when try call of methods in js file, failedtoinvoke error. understand problem can solved adding reference of js file in head section of aspx or html page. developing class library , not possible. know how tackle issue? using silverlight 4 , visual studio 2010.

add .js file library probject sounds have done, make sure build action "resource".

you can retrieve content application.getresourcestream :-

streamresourceinfo srijs = application.getresourcestream(new uri("yourassemblyname;component/mystuff.js", urikind.relative)); 

note structure of uri, assembly name of class library needed followed literal ";component". tells silverlight resource inside dll included in final application's xap.

now need turn content of info's stream property string:-

streamreader reader = new streamreader(srijs.stream, system.text.encoding.utf8); string js = reader.readtoend(); 

finally can inject javascript current page with:-

htmlpage.window.eval(js); 

thats it, global functions defined in js may invoked htmlpage.window.invoke.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -