error 0x800a138f - JavaScript runtime error: Unable to get property rows of undefined or null refe

Last Reply 10 days ago By dharmendr

Posted 13 days ago

Please help iam getting the above error please help

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="EnterMarks.aspx.vb" Inherits="SMIS2022WEB.EnterMarks" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <script type="text/javascript">
       function Showalert() {
          alert('Call JavaScript function from codebehind');
       }
    </script>   
</head>
<body>
    <form id="form1" runat="server" class="newStyle1">
        <asp:Panel ID="Panel1" runat="server" BorderColor="#FF3300" Font-Bold="True" Height="575px" Width="931px">
            <table class="auto-style1">
                <tr>
                    <td class="auto-style9" colspan="11">
                        SELECT THE CLASS ,STREAM AND SUBJECT FROM THE LISTS BELOW AND CLICK [GO] TO START ENTERING MARKS</td>
                </tr>
                <tr>
                    <td class="auto-style9" rowspan="2"><strong>Class</strong></td>
                    <td class="auto-style13" rowspan="2"><strong>
                        <asp:DropDownList ID="DropDownList1Class" runat="server" DataSourceID="Classdr" DataTextField="CLASS" DataValueField="CLASS" AutoPostBack="True">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="Classdr" runat="server" ConnectionString="<%$ ConnectionStrings:SMIS2022ConnectionString %>" SelectCommand="SELECT [CLASS] FROM [CLASS]"></asp:SqlDataSource>
                        </strong></td>
                    <td class="auto-style6" rowspan="2"><strong>Subject</strong></td>
                    <td class="auto-style9" colspan="4" rowspan="2"><strong>
                        <asp:DropDownList ID="DropDownList3Subject" runat="server" DataSourceID="SqlDataSource1" DataTextField="subject" DataValueField="subject" Height="28px" Width="301px">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SMIS2022ConnectionString %>" SelectCommand="SELECT [subject] FROM [subjects]"></asp:SqlDataSource>
                        </strong></td>
                    <td class="auto-style11" colspan="4">TEACHERS&#39; LISTS FOR RECORDING MARKS</td>
                </tr>
                <tr>
                    <td class="auto-style24" colspan="2">Print Marks Entry Sheets</td>
                    <td class="auto-style12" colspan="2">&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style9">Stream</td>
                    <td class="auto-style13">
                        <asp:DropDownList ID="DropDownList2Stream" runat="server" DataSourceID="Streamddr" DataTextField="Stream" DataValueField="Stream">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="Streamddr" runat="server" ConnectionString="<%$ ConnectionStrings:SMIS2022ConnectionString %>" SelectCommand="SELECT [Stream] FROM [Streamdata]"></asp:SqlDataSource>
                    </td>
                    <td class="auto-style6">&nbsp;</td>
                    <td class="auto-style9">
                        <asp:Label ID="lblTotalBK" runat="server" />
                    </td>
                    <td class="auto-style9">
                        <asp:Button ID="Button1" runat="server" Text="Go" />
                    </td>
                    <td class="auto-style9" colspan="2">
                        <asp:Button ID="Button3" runat="server" style="height: 26px" Text="Save Data" />
                    </td>
                    <td class="auto-style24">Load Assesments</td>
                    <td class="auto-style12">
                        <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True" />
                    </td>
                    <td class="auto-style12" colspan="2">&nbsp;</td>
                </tr>
                <tr>
                    <td class="auto-style20">&nbsp;</td>
                    <td class="auto-style21">
                        &nbsp;</td>
                    <td class="auto-style16"></td>
                    <td class="auto-style23">
                        &nbsp;</td>
                    <td class="auto-style22" colspan="2">
                        &nbsp;</td>
                    <td class="auto-style22">
                        &nbsp;</td>
                    <td class="auto-style25">
                        <asp:Button ID="Button2" runat="server" Text="Print List" />
                    </td>
                    <td class="auto-style18">
                        <asp:Button ID="Button4" runat="server" Text="Back To Menu" />
                    </td>
                    <td class="auto-style18">
                        <asp:Label ID="CurrentLogin" runat="server" Text="Label"></asp:Label>
                    </td>
                    <td class="auto-style18">&nbsp;</td>
                </tr>
                <tr>
                    <td aria-hidden="True" class="auto-style20" hidden="hidden">
                        &nbsp;</td>
                    <td aria-hidden="True" class="auto-style20" colspan="10" hidden="hidden">
                        <asp:Label ID="k11" runat="server" Text="k11"></asp:Label>
                        <asp:Label ID="k12" runat="server" Text="k12"></asp:Label>
                        <asp:Label ID="k13" runat="server" Text="k13"></asp:Label>
                        <asp:Label ID="k14" runat="server" Text="k14"></asp:Label>
                        <asp:Label ID="k15" runat="server" Text="k15"></asp:Label>
                        <asp:Label ID="k16" runat="server" Text="k16"></asp:Label>
                        <asp:Label ID="k17" runat="server" Text="k17"></asp:Label>
                        <asp:Label ID="k10" runat="server" Text="k10"></asp:Label>
                        <asp:Label ID="k9" runat="server" Text="k9"></asp:Label>
                        <asp:Label ID="k8" runat="server" Text="k8"></asp:Label>
                        <asp:Label ID="k7" runat="server" Text="k7"></asp:Label>
                        <asp:Label ID="k6" runat="server" Text="k6"></asp:Label>
                        <asp:Label ID="k5" runat="server" Text="k5"></asp:Label>
                        <asp:Label ID="k4" runat="server" Text="k4"></asp:Label>
                        <asp:Label ID="k3" runat="server" Text="k3"></asp:Label>
                        <asp:Label ID="k2" runat="server" Text="k2"></asp:Label>
                        <asp:Label ID="k1" runat="server" Text="k1"></asp:Label>
                        <asp:Label ID="r1" runat="server" Text="r1"></asp:Label>
                        <asp:Label ID="r2" runat="server" Text="r2"></asp:Label>
                        <asp:Label ID="r3" runat="server" Text="r3"></asp:Label>
                        <asp:Label ID="r4" runat="server" Text="r4"></asp:Label>
                        <asp:Label ID="r5" runat="server" Text="r5"></asp:Label>
                        <asp:Label ID="r6" runat="server" Text="r6"></asp:Label>
                        <asp:Label ID="r7" runat="server" Text="r7"></asp:Label>
                        <asp:Label ID="r8" runat="server" Text="r8"></asp:Label>
                        <asp:Label ID="r9" runat="server" Text="r9"></asp:Label>
                        <asp:Label ID="r10" runat="server" Text="r10"></asp:Label>
                        <asp:Label ID="r11" runat="server" Text="r11"></asp:Label>
                        <asp:Label ID="r12" runat="server" Text="r12"></asp:Label>
                        <asp:Label ID="r13" runat="server" Text="r13"></asp:Label>
                        <asp:Label ID="r14" runat="server" Text="r14"></asp:Label>
                        <asp:Label ID="r15" runat="server" Text="r15"></asp:Label>
                        <asp:Label ID="r16" runat="server" Text="r16"></asp:Label>
                        <asp:Label ID="r17" runat="server" Text="r17"></asp:Label>
                        <asp:Label ID="Kholds" runat="server" Text="Kholds"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="auto-style7" colspan="11">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                  <asp:ScriptManager ID="ScriptManager1" runat="server">
                                  </asp:ScriptManager>
                                  <asp:GridView ID="StudentGridMarks" runat="server" AllowPaging="True" AutoGenerateColumns="False" OnPageIndexChanging="OnPageIndexChanging" PageSize="45" >
                                      <Columns>
                                           <asp:TemplateField>
                                            <HeaderTemplate>
                                                <asp:CheckBox ID="chkAll" runat="server" AutoPostBack="true" />
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" Enabled="False" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                          <asp:TemplateField HeaderText="Admno">
                                              <EditItemTemplate>
                                                  <asp:TextBox ID="TextBox3" runat="server" Text='<%# Eval("admno") %>'></asp:TextBox>
                                              </EditItemTemplate>
                                              <ItemTemplate>
                                                  <asp:Label ID="Label3" runat="server" Text='<%# Bind("admno") %>' Visible="False"></asp:Label>
                                                  <asp:TextBox ID="admno" runat="server" Text='<%# Eval("admno") %>' Height="16px" Width="93px" ReadOnly="True"></asp:TextBox>
                                              </ItemTemplate>
                                          </asp:TemplateField>
                                          <asp:TemplateField HeaderText="Name">
                                              <EditItemTemplate>
                                                  <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Name") %>'></asp:TextBox>
                                              </EditItemTemplate>
                                              <ItemTemplate>
                                                  <asp:TextBox ID="Name" runat="server" Text='<%# Eval("Name") %>' Height="16px" Width="186px" ReadOnly="True"></asp:TextBox>
                                                  <asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>' Visible="False"></asp:Label>
                                              </ItemTemplate>
                                          </asp:TemplateField>
                                          <asp:TemplateField HeaderText="Class">
                                              <EditItemTemplate>
                                                  <asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("Class") %>' Height="16px" Width="58px"></asp:TextBox>
                                              </EditItemTemplate>
                                              <ItemTemplate>
                                                  <asp:Label ID="Label2" runat="server" Text='<%# Bind("Class") %>' Visible="False"></asp:Label>
                                                  <asp:TextBox ID="Class" runat="server" Text='<%# Eval("Class") %>' Height="16px" Width="32px" ReadOnly="True"></asp:TextBox>
                                              </ItemTemplate>
                                          </asp:TemplateField>
                                           <asp:TemplateField HeaderText="Stream">
                                               <EditItemTemplate>
                                                   <asp:TextBox ID="TextBox4" runat="server" Height="16px" Text='<%# Bind("Stream") %>' Width="42px"></asp:TextBox>
                                               </EditItemTemplate>
                                               <ItemTemplate>
                                                   <asp:Label ID="Label4" runat="server" Text='<%# Bind("Stream") %>' Visible="False"></asp:Label>
                                                   <asp:TextBox ID="Stream" runat="server" Height="16px" Text='<%# Eval("Stream") %>' Width="41px" ReadOnly="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="Score">
                                               <EditItemTemplate>
                                                   <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Score") %>'></asp:TextBox>
                                               </EditItemTemplate>
                                               <ItemTemplate>
                                                   <asp:Label ID="Label5" runat="server" Text='<%# Bind("Score") %>' Visible="False"></asp:Label>
                                                   
                                                    <asp:TextBox ID="Score" runat="server" Text='<%#Eval("score") %>' CssClass="Score" onkeyup="enter(this)" AutoPostBack="true" OnTextChanged="Score_TextChanged" Height="16px"  Width="31px"></asp:TextBox>
                                                    </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="Agg">
                                               <EditItemTemplate>
                                                   <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Grade") %>'></asp:TextBox>
                                               </EditItemTemplate>
                                               <ItemTemplate>
                                                   <asp:Label ID="Label6" runat="server" Text='<%# Bind("Grade") %>' Visible="False"></asp:Label>
                                                   <asp:TextBox ID="Agg" runat="server" Height="16px" ReadOnly="True" Text='<%# Eval("Grade") %>' Width="29px"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="Remarks">
                                               <EditItemTemplate>
                                                   <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("Remark") %>'></asp:TextBox>
                                               </EditItemTemplate>
                                               <ItemTemplate>
                                                   <asp:Label ID="Label7" runat="server" Text='<%# Bind("Remark") %>' Visible="False"></asp:Label>
                                                 <asp:TextBox ID="Remarks" runat="server" Text='<%# Eval("Remark") %>' CssClass="Remarks"
                                                     AutoPostBack="True" OnTextChanged="Remarks_TextChanged" Height="18px" onkeyup="enter(this)" Width="431px"></asp:TextBox>         
                                                    </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="UserName">
                                               <EditItemTemplate>
                                                   <asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>
                                               </EditItemTemplate>
                                               <ItemTemplate>
                                                   <asp:Label ID="Label8" runat="server" Visible="False"></asp:Label>
                                                   <asp:TextBox ID="UserName" runat="server" Text='<%# Eval("Username") %>' Height="16px" Width="106px" ReadOnly="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="DateTime">
                                               <EditItemTemplate>
                                                   <asp:TextBox ID="TextBox9" runat="server"></asp:TextBox>
                                               </EditItemTemplate>
                                               <ItemTemplate>
                                                   <asp:Label ID="Label9" runat="server" Visible="False"></asp:Label>
                                                   <asp:TextBox ID="DateTime" runat="server" Height="16px" Text='<%# Eval("time") %>' Width="151px" ReadOnly="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>     
                                           <asp:TemplateField HeaderText="A1">
                                               <ItemTemplate>

                                                   <asp:TextBox ID="A1" runat="server" Height="16px"  Text='<%# Eval("A1")  %>' CssClass="A1" onkeyup="enter2(this)" Width="29px" AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A2">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A2" runat="server" Height="16px"  Text='<%# Eval("A2") %>' CssClass="A2" onkeyup="enter2(this)" Width="29px" AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A3">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A3" runat="server" Height="16px"  Text='<%# Eval("A3") %>' CssClass="A3" onkeyup="enter2(this)" Width="29px" AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A4">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A4" runat="server" Height="16px"  Text='<%# Eval("A4") %>' CssClass="A4" onkeyup="enter2(this)" Width="29px" AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A5">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A5" runat="server" Height="16px"  Text='<%# Eval("A5") %>' CssClass="A5" onkeyup="enter2(this)" Width="29px" AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A6">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A6" runat="server" Height="16px"  Text='<%# Eval("A6") %>' CssClass="A6" onkeyup="enter2(this)" Width="29px"  AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A7">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A7" runat="server" Height="16px"  Text='<%# Eval("A7") %>' CssClass="A7" onkeyup="enter2(this)" Width="29px"  AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A8">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A8" runat="server" Height="16px"  Text='<%# Eval("A8") %>' CssClass="A8" onkeyup="enter2(this)" Width="29px"  AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A9">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A9" runat="server" Height="16px"  Text='<%# Eval("A9") %>' CssClass="A9" onkeyup="enter2(this)" Width="29px" AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                           <asp:TemplateField HeaderText="A10">
                                               <ItemTemplate>
                                                   <asp:TextBox ID="A10" runat="server" Height="16px"  Text='<%# Eval("A10") %>' CssClass="A10" onkeyup="enter2(this)" Width="29px"  AutoPostBack="True"></asp:TextBox>
                                               </ItemTemplate>
                                           </asp:TemplateField>
                                      </Columns>
                                  </asp:GridView>
                                 <asp:HiddenField ID="hfRowIndex" runat="server" />
                                 <asp:HiddenField ID="hfCellIndex" runat="server" />
                                 <asp:Label ID="lblTotal" runat="server" />                         
                            </ContentTemplate>
                        </asp:UpdatePanel>
    
<script type="text/javascript">
    function enter(obj) {
        var tr = obj.parentNode.parentNode;
        var cellIndex = obj.parentNode.cellIndex;
        var rowIndex = obj.parentNode.parentNode.rowIndex;
        if (event.keyCode == 37) //Left
        {
            if (cellIndex > 0)
                tr.parentNode.rows[rowIndex].cells[cellIndex - 1].getElementsByTagName('INPUT')[0].focus();
            GetSelectedRow(obj)
            // return;
        }
        if (event.keyCode == 38) //Up
        {
            if (rowIndex > 1)
                tr.parentNode.rows[rowIndex - 1].cells[cellIndex].getElementsByTagName('INPUT')[0].focus();
            GetSelectedRow(obj)
            // return;
        }
        if (event.keyCode == 39) //Right
        {
            if (cellIndex < tr.cells.length - 1)
                tr.parentNode.rows[rowIndex].cells[cellIndex + 1].getElementsByTagName('INPUT')[0].focus();
            GetSelectedRow(obj)
            //return;
        }
        if (event.keyCode == 40) //Down
        {
            if (rowIndex < tr.parentNode.rows.length - 1)
                tr.parentNode.rows[rowIndex + 1].cells[cellIndex].getElementsByTagName('INPUT')[0].focus();
            GetSelectedRow(obj)
            //return;
        }
    };
 
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm != null) {
        prm.add_endRequest(function (sender, e) {
            if (sender._postBackSettings.panelsToUpdate != null) {
                var rowIndex = parseInt(document.getElementById("hfRowIndex").value);
                var row = document.getElementById("StudentGridMarks").rows[rowIndex + 2];
                if (typeof (row) != "undefined") {
                    var celIndex = parseInt(document.getElementById("hfCellIndex").value);
                    var controls = row.cells[celIndex].getElementsByTagName("INPUT");
                    for (var i = 0; i < controls.length; i++) {
                        switch (controls[i].className) {
                            case "Remarks":
                                controls[i].focus();
                                return;
                                break;
                            case "Score":
                                controls[i].focus();
                                return;
 
                            default:
                        }
                    }
                }
            }
        });
    }
</script>
                    </td>
                </tr>
            </table>
        </asp:Panel>
                            
       <script type="text/javascript">
    function GetSelectedRow(UserLink) {
    var row = UserLink.parentNode.parentNode;
    var rowIndex = row.rowIndex - 1;
    var userId = row.cells[0].innerHTML;
    var lable = row.getElementsByTagName("input")[5].value;
    if (lable == null || lable == "") {
    //if (lable == 100){
        // row.getElementsByTagName("input")[8].value = "d";
      
        return true;
    }
    if (lable >= 0 && lable <= 100) {
        return true;
    }
    else {
        alert("Must be between 1 and 100");
        return false;
    }
}
</script>
    <div>
    
    </div>
    </form>
     
 
</body>
<script type="text/javascript">
    function enter2(obj) {
        var tr = obj.parentNode.parentNode;
        var cellIndex = obj.parentNode.cellIndex;
        var rowIndex = obj.parentNode.parentNode.rowIndex;
        if (event.keyCode == 37) //Left
        {
            if (cellIndex > 0)
                tr.parentNode.rows[rowIndex].cells[cellIndex - 1].getElementsByTagName('INPUT')[0].focus();
            //  GetSelectedRow(obj)
            return;
        }
        if (event.keyCode == 38) //Up
        {
            if (rowIndex > 1)
                tr.parentNode.rows[rowIndex - 1].cells[cellIndex].getElementsByTagName('INPUT')[0].focus();
            //  GetSelectedRow(obj)
            return;
        }
        if (event.keyCode == 39) //Right
        {
            if (cellIndex < tr.cells.length - 1)
                tr.parentNode.rows[rowIndex].cells[cellIndex + 1].getElementsByTagName('INPUT')[0].focus();
            // GetSelectedRow(obj)
            //return;
        }
        if (event.keyCode == 40) //Down
        {
            if (rowIndex < tr.parentNode.rows.length - 1)
                tr.parentNode.rows[rowIndex + 1].cells[cellIndex].getElementsByTagName('INPUT')[0].focus();
            //  GetSelectedRow(obj)
            return;
        }
    };
 
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm != null) {
        prm.add_endRequest(function (sender, e) {
            if (sender._postBackSettings.panelsToUpdate != null) {
                var rowIndex = parseInt(document.getElementById("hfRowIndex").value);
                var row = document.getElementById("StudentGridMarks").rows[rowIndex + 2];
                if (typeof (row) != "undefined") {
                    var celIndex = parseInt(document.getElementById("hfCellIndex").value);
                    var controls = row.cells[celIndex].getElementsByTagName("INPUT");
                    for (var i = 0; i < controls.length; i++) {
                        switch (controls[i].className) {
 
                            case "A1":
                                controls[i].focus();
                                return;
                                break;
                            case "A2":
                                controls[i].focus();
                                return;
                                break;
                            case "A3":
                                controls[i].focus();
                                return;
                                break;
                            case "A4":
                                controls[i].focus();
                                return;
                                break;
                            case "A5":
                                controls[i].focus();
                                return;
                                break;
                            case "A6":
                                controls[i].focus();
                                return;
                                break;
                            case "A7":
                                controls[i].focus();
                                return;
                                break;
                            case "A8":
                                controls[i].focus();
                                return;
                                break;
                            case "A9":
                                controls[i].focus();
                                return;
                                break;
                            case "A10":
                                controls[i].focus();
                                return;
                                break;
 
                            default:
                        }
                    }
                }
            }
        });
    }
</script>
</html>

 

 

You are viewing reply posted by: Andrea 13 days ago.
Posted 13 days ago
Hi @makumbi,
Please try the following

JavaScript runtime error: Unable to get property 'createRange' of undefined or null reference

It might help you.

Cheers Andrea.