Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Kiswar Malik   on May 25 In Asp.net Category.

  
Question Answered By: Anthony Smith   on May 25

Change the property of the JS file to Embedded Resource.

Extract it with this.(add ref to System.Reflection)


Assembly asm = Assembly.GetExecutingAssembly();
if (asm != null)
{
// create stream to the embedded file(change js file name to what suits
you)
Stream stm = asm.GetManifestResourceStream(asm.GetName().Name + "." +
"JavaScript1.JS");
StreamReader reader = new StreamReader(stm);
// read it in
string _clientScript = reader.ReadToEnd();
// clean up
reader.Close();
stm.Close();
}

_clientScript now contains the JS.

Share: