hai friends,

i am doing project in asp.net codebehind C#. my project name is ONLINE EXAMINATION. In this we have one problem, if one question is answered then the student does not go back, we have to stop the Internet Explorer back button and restrict the user to go back.


this is the main event in my project, and i need it immediately.

Dani AI

Generated

Disabling the browser Back button is not reliable and not recommended. Browsers give control to users, and client-side tricks can be bypassed or break accessibility. For an online exam the correct approach is to enforce progression on the server: record which question the student is allowed to view/answer and refuse or redirect any requests for earlier questions. That prevents a user from revisiting or re-submitting a question even if the browser shows a cached page. As hinted, client caching touches the problem surface, but it alone does not stop a determined user; server-side checks are required (this is why your meta-only attempt did not solve the issue, ).

A simple, practical pattern for ASP.NET WebForms:

  • Keep the current question index in Session or in the database (persist for reconnects).
  • On each question request, compare the requested index to the allowed index; redirect or show a message if it is older.
  • On submit, save the answer server-side and use Post-Redirect-Get (Response.Redirect) to avoid repost/resubmit.

Example (simplified):

protected void Page_Load(object sender, EventArgs e)
{
    int allowed = Session["CurrentQuestion"] != null ? (int)Session["CurrentQuestion"] : 1;
    int requested;
    if (!int.TryParse(Request.QueryString["q"], out requested)) requested = 1;

    if (!IsPostBack)
    {
        if (requested < allowed)
        {
            Response.Redirect("Exam.aspx?q=" + allowed);
            return;
        }
        // load question 'requested'
    }
}

protected void btnSubmit_Click(object sender, EventArgs e)
{
    // save answer to DB/session
    int current = Session["CurrentQuestion"] != null ? (int)Session["CurrentQuestion"] : 1;
    current++;
    Session["CurrentQuestion"] = current;
    Response.Redirect("Exam.aspx?q=" + current); // PRG
}

Extra notes: persist progress in the DB for multi-tab or reconnect handling; use per-question one-time tokens to prevent replay; log timestamps for auditing. Client-side history hacks (history.pushState/onpopstate) can be added as a deterrent but should never replace server-side validation.

Recommended Answers

All 3 Replies

man i dont know how to stop the back button in ie.
but u can prevent the user from going back by using the <meta> expires.
<meta http-equiv= "expires" content = "dd-mmm-yyyy time">
the date should be old so when the user click next, the pages directly will be expires from the cashe.

do it and tell me wht is happening with u.

man i dont know how to stop the back button in ie.
but u can prevent the user from going back by using the <meta> expires.
<meta http-equiv= "expires" content = "dd-mmm-yyyy time">
the date should be old so when the user click next, the pages directly will be expires from the cashe.

do it and tell me wht is happening with u.

hai ,

Thank u for ur immediate reply and i check and tell to u.

hai,

i does not work . i am happy if u help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.