0

I have a few buttons that serve to hide or reveal other elements on the page when clicked.

The buttons are of the following format:

<button type="button" id="BTN" onclick="takeAction()">

The JavaScript is of the format:

<script type="text/javascript">
    function takeAction() {
         document.getElementById("ELEMENT1_HDR").style.display = "";
         document.getElementById("ELEMENT1_BODY").style.display = "";
         document.getElementById("ELEMENT2").style.display = "none";
         document.getElementById("ELEMENT3").style.display = "none";
     }
</script>

Locally, this works just fine when using strictly HTML and JavaScript, as well as when other features are using c# in the .aspx.cs files.

However, as soon as I publish it and access it via the ip address, clicking the buttons has no effect. When doing an Inspect Element and clicking on the button I receive the following error:

The value of the property 'takeAction' is null or undefined, not a Function object

What am I doing wrong that it works in my developing environment, but not in my simulated Prod environment?

I have tried putting the <script> tag contents under the <header> as well as <body> tags to no variance on publishing. Could Visual Studio be corrupting it on publishing?

Somehow: When I start on page1 and click the "View" button to navigate to the specific record, the published version is loading the record view page to the screen but is keeping the page1 name. When done locally, it actually changes the page address - so that could be why the functions work locally but not in the published environment

I've selected a function that exists on both page1 and page2, called noCanDoYet() which merely calls the alert function and posts to the screen the message: "This feature is not yet implemented". I get the same error for this function even though it is defined on both pages.

alert("help") works though.

Could the following means of navigation to the specific record be causing issue in a Prod type environment that the local environment doesn't have?

protected void navigateView(object sender, EventArgs e)
{
    LinkButton lb = (LinkButton)sender;
    setCurrentlySelectedRecord(lb.CommandArgument);
    setViewEdit("View");
    Server.Transfer("page2.aspx");
}
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
wolfsshield
  • 757
  • 5
  • 14
  • 1
    On your prod environment, if you view the source, is your script tag there? Try CTRL+F5 to force a refresh incase it is out of date. – NibblyPig Mar 07 '19 at 16:46
  • It is there. I see: `` – wolfsshield Mar 07 '19 at 16:51
  • Are there any errors in the console of the debug tools? What happens if you use the immediate window in the browser debug tools to call `takeAction()` yourself? – NibblyPig Mar 07 '19 at 16:55
  • Console of Developer Tools has in addition to the above quoted error: The attached page targets document mode 5. Some console APIs and features may not be available. Then it proceeds into the error with SCRIP5007:... Interesting though it says the file is one thing when the page it is on should be referencing a different file name...so if it is pointing to the wrong file, no wonder it cannot find the function. – wolfsshield Mar 07 '19 at 17:03

1 Answers1

0

I think the problem has to do with IE11. I just installed Chrome, and everything works great.

IE11 now works as well with adding <meta http-equiv="x-ua-compatible" content="IE=edge; charset=UTF-8"/> in the <head> just prior to my <script>.

Thanks, @JhWebDevGuy

wolfsshield
  • 757
  • 5
  • 14
  • I'd recheck your answer. Are you required to support Internet Explorer 11? If so, you still have your problem. As much as developers would like to say "No More IE" and despite Microsoft not even supporting IE themselves, there are enough users out there that _still use_ Internet Explorer. If you don't need to support it be wary that you do lose some users by continuing with that decision. Now Regarding the SCRIP5007 error, [THIS](https://stackoverflow.com/questions/5787245/ie9-javascript-error-script5007-unable-to-get-value-of-the-property-ui-obje) article has the answer for that. – JhWebDev Mar 11 '19 at 19:49
  • That looks interesting, but I don't know what that means. I hate showing my ignorance... – wolfsshield Mar 11 '19 at 21:14
  • 1
    @JhWebDevGuy Nevermind, I found the `` further down and that works! Thanks!! Specifically: https://stackoverflow.com/a/48320394/11035837 – wolfsshield Mar 11 '19 at 21:25