I am currently working on an ASP.NET webforms application and I've encountered an issue with injecting a script into the page from a web control. The script is located in the same folder as the control:
Here is a screenshot showcasing the issue
My approach so far has been:
[ToolboxData("<{0}:MyWebControl runat=server></{0}:MyWebControl>")]
[System.Drawing.ToolboxBitmap(typeof(MyWebControl))]
public class MyWebControl : Image
{
//...
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
string scriptStr = "<script src=\"my_script.js\" type=\"text/javascript\">";
ClientScriptManager csm = Page.ClientScript;
csm.RegisterClientScriptBlock(this.Page.GetType(), "MyScriptTag", scriptStr);
//...
}
}
Upon checking if the script was successfully injected, Chrome displayed this error:
Screenshot showing the error message
I suspect that the issue lies within script src=\"my_script.js\"
, even after attempting to change the path multiple times without success.
Your assistance in resolving this matter would be greatly appreciated. Thank you!