Friday, 12 February 2016

JavaScript - how to fix error - 0x800a138f - JavaScript runtime error: Unable to get property 'submit' of undefined or null reference

Watch this on YouTube:




0x800a138f - JavaScript runtime error: Unable to get property 'submit' of undefined or null reference


Replace

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JavaScriptSubmit.aspx.cs" Inherits="WebTest.JavaScriptSubmit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function doSomething() {
            document.second.submit();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="doSomething();" />
    </div>
    </form>
    <form method="post" action="./JavaScriptSubmit.aspx" id="second"></form>
</body>
</html>

with

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JavaScriptSubmit.aspx.cs" Inherits="WebTest.JavaScriptSubmit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function doSomething() {
            this.form1.submit();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="doSomething();" />
    </div>
    </form>
    <form method="post" action="./JavaScriptSubmit.aspx" id="second"></form>
</body>
</html>

No comments:

Post a Comment