G
Guest
for some reason i can't access a resource (.js) if the control files and the
resource are in a subfolder off the project root or just the resource is in a
subfolder.
the code is as follows ( this is an example with the resourse in a
sub-folder called Resources):
private void RegisterScript(Control targetControl) {
String pageScriptName = "Cbs.Ui.Controls.Resources.ControlScript";
if ( !this.Page.IsClientScriptBlockRegistered(pageScriptName) ) {
using (System.IO.StreamReader reader = new
System.IO.StreamReader(typeof(Cbs.Ui.Controls.FirstFocus).Assembly.GetManifestResourceStream(typeof(Cbs.Ui.Controls.FirstFocus),
"Cbs.Ui.Controls.Resources.ControlScript.js"))) {
String script = "<script language='javascript' type='text/javascript'
}
}
the code failes on the using line with the error:
Value cannot be null. Parameter name: stream
Everything works fine if its all in the root and refer to the script as just
"ControlScript.js"
I understand that the fully qualified name of a resource in a sub-folder
should be <namespace>.<subfolder>.<resourcename>.<extension>.
Am i missing something?
Thanks,
Christian
resource are in a subfolder off the project root or just the resource is in a
subfolder.
the code is as follows ( this is an example with the resourse in a
sub-folder called Resources):
private void RegisterScript(Control targetControl) {
String pageScriptName = "Cbs.Ui.Controls.Resources.ControlScript";
if ( !this.Page.IsClientScriptBlockRegistered(pageScriptName) ) {
using (System.IO.StreamReader reader = new
System.IO.StreamReader(typeof(Cbs.Ui.Controls.FirstFocus).Assembly.GetManifestResourceStream(typeof(Cbs.Ui.Controls.FirstFocus),
"Cbs.Ui.Controls.Resources.ControlScript.js"))) {
String script = "<script language='javascript' type='text/javascript'
this.Page.RegisterClientScriptBlock(pageScriptName, script);\r\n<!--\r\n" + reader.ReadToEnd() + "\r\n//-->\r\n</script>";
}
}
the code failes on the using line with the error:
Value cannot be null. Parameter name: stream
Everything works fine if its all in the root and refer to the script as just
"ControlScript.js"
I understand that the fully qualified name of a resource in a sub-folder
should be <namespace>.<subfolder>.<resourcename>.<extension>.
Am i missing something?
Thanks,
Christian