You must Sign In to post a response.
  • Category: .NET

    Return error msg from aspx to html page

    Html Page
    -------------
    <script type="text/javascript">
    function getQuerystring() {
    var q = document.location.toString();
    q = q.split("?");
    if (q.length > 1) {
    q = q[1].split("&");
    var str = ""
    for (i = 0; i < q.length; i++) {
    tmp = q[i].split("=")
    str += i + tmp[0] + tmp[1];
    }
    if (str != '') {
    alert('Lab Reference Number or Password is incorrect. Please verify and enter again.');
    }
    }
    }
    onload = function () {
    getQuerystring()
    }
    </script>

    .aspx
    -----
    ssOnline_Report = http://localhost:2695/SLIMS/LoginPage.html;
    Response.Redirect(sOnline_Report + "?Error='Error'", true);
    return;

    here i return same msg when username or passwor is incorrect
    i need to return username is incorrect error1
    password is incorrect error 2
    how can i do ?
  • #761892
    Hi

    If you need check username and pwd show separate alert message means you can try this code


    <script type="text/javascript">
    function checkuserdetails() {
    var username = document.getElementById("TxtUserName").value;
    var pwdnam = document.getElementById("TxtPwd").value;
    if (username == "") {
    alert(' UserName Is Empty');
    return false;
    }

    if (pwdnam == "") {
    alert(' Password Is Empty');
    return false;
    }

    }
    </script>
    </head>
    <body>
    <form id="form1" runat="server">



    <table>
    <tr>
    <td>
    UserName: <asp:TextBox ID="TxtUserName" runat="server"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td>
    Password: <asp:TextBox ID="TxtPwd" runat="server"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td>
    <asp:Button ID="btsubmit" Text="Submit" runat="server" OnClientClick="return checkuserdetails();" />
    </td>
    </tr>
    </table>

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


Sign In to post your comments