locked
LMS issue RRS feed

  • Question

  • User-209021226 posted

    I am working on LMS using web forms, thee is a quiz system which contains number of questions, user will not allowed to go back to edit the last question which has been done, right now when user click on back button of chrome it goes back and that is an issue, how to avoid this behavior.

    Friday, November 22, 2019 2:52 AM

Answers

  • User665608656 posted

    Hi Mushar,

    I am working on LMS using web forms, thee is a quiz system which contains number of questions, user will not allowed to go back to edit the last question which has been done, right now when user click on back button of chrome it goes back and that is an issue, how to avoid this behavior.

    We cannot disable the browser back button functionality, but what we can do is prevent them.

    You can add this js code in your first page:

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function DisableBackButton() {
                window.history.forward()
            }
            DisableBackButton();
            window.onload = DisableBackButton;
            window.onpageshow = function (evt) { if (evt.persisted) DisableBackButton() }
            window.onunload = function () { void (0) }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                This is First Page! 
    <a href="NewPage.aspx">NewPage.aspx</a> </div> </form> </body> </html>

    Here is the result of this work demo:

    For more details, you could refer to this link , there are also many other methods for your reference:

    Disabling backbutton of browser in C#

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 22, 2019 6:37 AM

All replies

  • User665608656 posted

    Hi Mushar,

    I am working on LMS using web forms, thee is a quiz system which contains number of questions, user will not allowed to go back to edit the last question which has been done, right now when user click on back button of chrome it goes back and that is an issue, how to avoid this behavior.

    We cannot disable the browser back button functionality, but what we can do is prevent them.

    You can add this js code in your first page:

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function DisableBackButton() {
                window.history.forward()
            }
            DisableBackButton();
            window.onload = DisableBackButton;
            window.onpageshow = function (evt) { if (evt.persisted) DisableBackButton() }
            window.onunload = function () { void (0) }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                This is First Page! 
    <a href="NewPage.aspx">NewPage.aspx</a> </div> </form> </body> </html>

    Here is the result of this work demo:

    For more details, you could refer to this link , there are also many other methods for your reference:

    Disabling backbutton of browser in C#

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 22, 2019 6:37 AM
  • User-209021226 posted

    I will test it and let you know, just engaged in database issues, thank you

    Tuesday, November 26, 2019 12:37 PM