I found some JavaScript code on the web that I want to add to my custom web part so that I can modify a PageViewerWebPart's height to 100%. I just need to know what steps to take to call it. I added the JavaScript file to Visual Studio and called it Height100Percent.js and changed it to an embedded resource.
I think I need to use this to access the file from my C# code:
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Height100Percent.js");
But, I can't find out what method I need to call to execute my JavaScript file. What methods do I call, and should I include this code in CreateChildControls() or a different overridden method in the custom web part?
Below is something that I think resembles what should be done:
I added to my AssemblyInfo.cs:
[assembly: System.Web.UI.WebResource("ReportingMDMWebPart.Height100Percent.js", "text/js", PerformSubstitution = true)]
Created a method called RunJavaScript() which is called from the overridden CreateChildControls() method in my web part:
private void RunJavaScript()
{
Type resourceType = this.GetType();
string resourceName = "ReportingMDMWebPart.Height100Percent.js";
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager csm = Page.ClientScript;
// Register the client resource with the page.
csm.RegisterClientScriptResource(resourceType, resourceName);
}
My Height100Percent.js file is a duplicate of file on this page: Story of a mischievous Page Viewer Web Part.
But, I can't get the JavaScript to run at all. I've searched around for this quite a bit, but I can't seem to find anything that explains this process at all. Is there anything unusual about what I tried above?