Akhil Jain Ответов: 1

Ошибка выполнения Javascript: не удалось получить свойство 'onsubmit' неопределенной или нулевой ссылки и сохранить кнопку, не срабатывающую при кликинге


Цитата:
получение этой ошибки не в состоянии понять, почему она приходит, когда страница загружается и кнопка сохранения не срабатывает, когда я нажимаю на нее. пожалуйста, помогите заранее спасибо

Ошибка выполнения JavaScript: не удалось получить свойство 'onsubmit' неопределенного или нулевого ссылочного кода:


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ChangePassword.aspx.vb"
    Inherits="PRCManagementConsole.Web.ChangePassword" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <link rel="stylesheet" type="text/css" href="../css/cbre_wsm_screen.css" />
    <link rel="stylesheet" type="text/css" href="../css/BodyFramePages.css" />
    <title>Change Password</title>

    <script src="../Scripts/jquery-1.4.4.min.js" type="text/javascript"/>



    <style type="text/css">
        .style2
        {
            width: 97px;
        }
        .style3
        {
            width: 330px;
        }
    </style>


</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script type="text/javascript">
        function checknewtextbox() {
            //debugger
            var pass = document.getElementById("<%=txtNewPassword.ClientID %>");
            var filter = /^(?=.*[a-z])(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,20}/;
            // debugger;
            if (pass.value != '') {
                if (!filter.test(pass.value)) {
                    alert('Password Must contain Minimum 8 and Maximum 20 characters at least 1 Lowercase Alphabet, 1 Number and 1 Special Character');
                    pass.focus();
                    document.getElementById("<%=txtNewPassword.ClientID %>").value = '';
                    return false;
                }
                else
                    return true;
            }
            else return true;
        }
    </script>

            <div id="page_wrapper">
                <div id="wrapper_login_panel">
                    <div id="center_login_panel">
                        <table style="width: 100%;" id="maintable">
                           <%-- <tr style="height:33px">--%>
                            <%--</tr>--%>
                            <tr>
                            <td class="style2"> </td>
                                <%--<td class="style1">
                                     </td>--%>
                                <td style="vertical-align: left; text-align: left;" class="style3">
                                    <a href="http://www.cbre.com.au/" title="CBRE Home">
                                    <img id="img1" runat="server" src="../images/cbre_pulseresponse_logo.png" alt="CBRE Pulse Response"  width="280" />
                                    </a>
                                </td>
                                <td colspan="2">
                                    <div ID="ChangePassword" >
                                    <h1 style="width: 327px; left: 0px; top: 0px;">
                                    Change Password</h1>
                                        <br />
                                        <table cellpadding="0" cellspacing="0" style="width:100%; margin:2px;">
                                            <tr ID="trRowlabel" runat="server" 
                                                style="height:0px; margin:0px;padding: 0px 0px 0px 0px;">
                                                <td align="center" colspan="2" style="color: #393;padding: 0px 0px 10px 0px;">
                                                    <asp:Label ID="lblmsg" runat="server" Text="" Visible="true" />
                                                </td>
                                            </tr>

                                            <tr style="height:20px; margin:0px;">
                                                <td align="left" style="padding: 1px 1px 1px 50px;">
                                                    User Id:
                                                </td>
                                                <td style="padding: 0">
                                                    <asp:TextBox ID="txtUserId" runat="server" MaxLength="30" 
                                                        ToolTip="Enter your User Id" Width="160px" ReadOnly="true"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr style="height:20px; margin:0px;">
                                                <td align="left" style="padding: 1px 1px 1px 50px; ">
                                                    Old Password:
                                                </td>
                                                <td style="padding: 0">
                                                    <asp:TextBox ID="txtOldPassword" runat="server" CausesValidation="True" 
                                                        MaxLength="20" TextMode="Password" ToolTip="Please Enter your Old password" 
                                                        Width="160px"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="left" style="padding: 1px 1px 1px 50px;;">
                                                    New Password:
                                                </td>
                                                <td style="padding: 0">
                                                    <asp:TextBox ID="txtNewPassword" runat="server" MaxLength="20" onchange ="return checknewtextbox();" 
                                                        TextMode="Password" ToolTip="Please Enter your New password" Width="160px"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="left" style="padding: 1px 1px 1px 50px;">
                                                    Confirm Password:
                                                </td>
                                                <td style="padding: 0">
                                                    <asp:TextBox ID="txtConfirmPassword" runat="server" MaxLength="20" 
                                                        TextMode="Password" ToolTip="Please confirm password" Width="160px"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                            <td align="left" style="padding: 1px 1px 1px 50px;">
                                                   </td>
                                                <td align="left" colspan="2" style="padding: 0px 0px 0px 0px;">
                                                    <asp:Button ID="btnSave" runat="server" Text="Save" />
                                                  <%--    <Triggers>
                                                 <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click"/> 
                                                </Triggers>--%>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="left" colspan="2" style="padding: 1px 1px 1px 50px;">
                                                    <asp:Literal ID="litMessage" runat="server"></asp:Literal>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>

    </form>
</body>
</html>


внутренний код
Imports PRC.BO
Imports PRC.DTO
Imports DTO
Imports System.Web.Security
Imports System.Data.SqlClient
Imports System.Configuration
Imports DAL.Contacts

Public Class ChangePassword
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("temp") IsNot Nothing Then
            If Session("temp") = True Then
                lblmsg.Visible = True
                lblmsg.ForeColor = Drawing.Color.Red
                lblmsg.Text = "First Time login! Please Change your Password"
                Session.Remove("temp")
            End If
        Else
            lblmsg.Visible = False
            trRowlabel.Visible = False
        End If
        If Request.QueryString("Name") IsNot Nothing Then
            txtUserId.Text = Request.QueryString("Name")
        End If
    End Sub

    Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        litMessage.Text = ""
        If txtUserId.Text.Trim.Length = 0 Then
            litMessage.Text = litMessage.Text + "<a style=""font-weight: normal; font-size:10pt; color: red"">Please enter a User ID</a>"
            txtUserId.Focus()
        End If

        If txtOldPassword.Text.Trim.Length = 0 Then
            litMessage.Text = litMessage.Text + "</br><a style=""font-weight: normal; font-size:10pt; color: red"">Please enter Old Password</a>"
            txtOldPassword.Focus()
        End If

        If txtNewPassword.Text.Trim.Length = 0 Then
            litMessage.Text = litMessage.Text + "</br><a style=""font-weight: normal; font-size:10pt; color: red"">Please enter New Password </a>"
            txtNewPassword.Focus()
        End If

        If txtConfirmPassword.Text.Trim.Length = 0 Then
            litMessage.Text = litMessage.Text + "</br><a style=""font-weight: normal; font-size:10pt;  color: red"">Please Enter Confirm Password</a>"
            txtConfirmPassword.Focus()
        End If

        If Not (txtNewPassword.Text.Trim() = txtConfirmPassword.Text.Trim()) Then
            litMessage.Text = litMessage.Text + "</br><a style=""font-weight: normal; font-size:10pt;  color: red""> New & Confirm Passwords do not Match</a>"
            txtConfirmPassword.Focus()
        End If
        If Not (litMessage.Text = "") Then
            Exit Sub
        End If
        If String.Equals(txtOldPassword.Text, txtNewPassword.Text) Then
            litMessage.Text = "</br><a style=""font-weight: normal; font-size:10pt; color: red"">Old and New Password can't be Same</a>"
            Exit Sub
        End If
        Dim userPwd As New UserPassword

        Dim i As Integer = PRC.DTO.PRCContractor.Queries.PRC_AdminChangePassword(txtUserId.Text, userPwd.EncryptPassword(txtOldPassword.Text), userPwd.EncryptPassword(txtNewPassword.Text))

        If (i = 1) Then
            Dim MyScript As String = "alert('Password Updated Successfully!. Please Login Again!'); window.location = '/Login.aspx';"
            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "MyScript", MyScript, True)


        ElseIf (i = 3) Then
            litMessage.Text = "<a style=""font-weight: normal; font-size:10pt; color: red"">Old Password is Incorrect </a>"
            txtOldPassword.Focus()
        Else
            litMessage.Text = "<a style=""font-weight: normal; font-size:10pt; color: red"">Invalid User id</a>"
            txtUserId.Focus()
        End If




    End Sub
End Class


Что я уже пробовал:

getting this error not able to understand why it is coming when the page loads and save button not firing when i clicks it.please help thanks in advance

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

1 Ответов

Рейтинг:
1

Sandeep1003

Просто изменить

<script src="Scripts/jquery-1.8.2.min.js" type="text/javascript"/>

к
<script src="Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>