I'm making an ASP.NET webforms application and I have a problem with injecting a script into the page from a web control. The script is located in the same folder as control:
So I'm trying like:
[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);
//...
}
}
When I check if the script got injected successfully, Chrome gives me this:
I guess the problem is connected with script src=\"my_script.js\", but I tried changing the path for long with no success.
Looking forward for some help :)