Launching a Popup in ASP.NET followed by a Redirect

I have a unique custom CSS/HTML popup lightbox along with a form that contains a button.

My objective is, upon clicking the button:

  1. to open the popup
  2. followed by using Thread.Sleep
  3. and finally carry out a Response.Redirect to a different page.

Do you think this can be achieved?

Below is my HTML code snippet for reference:

<a href="#test"><img src="images/smallimg.jpg"/></a>
<div class="overlay" id="test">
<img src="images/bigimg.jpg"/>
<a href="#page" class="close">x Close</a>
</div>

Answer №1

To implement this in JavaScript, start by displaying the popup and then utilize the setTimeout(code,millisec,lang) function to trigger the ButtonClick event or function.

For ASP.NET, connect the setTimeout(code,millisec,lang) function from the backend.

Answer №2

Instead of making unnecessary server calls to have the main thread sleep for a set amount of time and then redirect, why not handle everything in JavaScript since you're already working on it?

To achieve this, display the box first and then utilize this snippet of JavaScript code to introduce a delay (for instance, 5 seconds - equivalent to 5000 milliseconds) before redirecting to another page:

setTimeout(function() {
    location.href = 'OtherPage.aspx';
}, 5000);

Answer №3

feel free to utilize the following script

alert(YourMessage);
location.replace(YourPageName);

alternatively, in your specific scenario

$('.overlay').show(); // make sure to apply appropriate styling to your div for it to appear as a popup
location.replace(YourPageName);

You also have the option of using jQuery Dialog.

If you encounter any issues, please inform me

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The container is not adjusting to the screen size correctly and the flex-direction: row is not functioning as

Struggling with setting up a basic layout in Angular for my application. While I have experience with Angular, the actual HTML/CSS design is new to me. No matter what I try, I can't seem to get this container to take up the whole screen width. Variou ...

trouble with the layout of the table

Could you assist me in improving the design to enhance data clarity? Your help would be greatly appreciated. Thank you for your anticipated response. CSS File: table-layout: fixed; width: 100%; border-collapse: collapse; table-layout: fixed; ove ...

Utilize Angular Material to assign the value of a mat-select component based on the FormControlName property

I am using Angular version 7 and have encountered an issue with a form I am creating. The form includes a dropdown select to choose an option, but when the page loads, the pre-defined value is not showing up. This page is specifically designed for editing ...

Issue with dropdown list removeClass function

I am encountering an issue with the Jquery dropdown list click function. The addClass method is working properly, but the removeClass method is not functioning as expected. When I click on the dropdown list, it does not hide. Here is a live demo: http://j ...

Using jQuery to toggle the visibility of div elements while displaying an indicator

A query arises regarding the utilization of JQuery to facilitate toggling the visibility of text divs. The question pertains to how one can incorporate an indicator - such as an up and down arrow graphic - to denote whether the divs are open or closed. Sug ...

I've been stuck on this for the past hour, trying to figure out why /js/bootstrap.min.js can't be located

I'm having an issue with the code in base.html while trying to create a bootstrap starter template. I copied it from bootstrap but when I run it, I get an error related to /js/bootstrap.min.js. Can someone help me figure out what's wrong? Thank y ...

Ensuring that the contents hidden by overflow:hidden remain truly concealed

When applying overflow: hidden; to a div, I have encountered situations where keyboard actions can still cause the div to scroll, even without visible scrollbars. This makes it difficult to return the div to its original state. Are there any additional ste ...

How to dynamically change the border-top color of an <a> tag in a menu using a jQuery loop

I am interested in adding a colorful border-top to my menu using jQuery. I know this can be achieved with HTML by including style="border-top-color: red;", but I want to explore the jQuery method. Here is what I have attempted so far: var colors = [ ...

ajax refresh isn't functioning

I need help with updating a combobox with the correct value when a button is clicked. The requirement is that after the user selects a year from the combobox, enters a day in the 'HolidayYearAllocation' input box, and clicks the button, the &apo ...

Creating multiple lines with kineticjs in a HTML5 environment can be a

Referencing the following page: KineticJS - Drawing Lines with Mouse KineticJs is effective in creating lines, shapes, and enabling drag-and-drop functionality. The provided example consistently redraws the same line, prompting the question of how to draw ...

Obtain CSS3 gradient background-color of an element using JavaScript

Currently, I am using the following JavaScript (jQuery) to retrieve the background color (in RGB) of various other div elements: $theColor = $(this).css("background-color"); This method works perfectly, except when dealing with CSS3 gradients. For insta ...

If ListItem.Value is not set, it will override Text

Whenever you assign a value to ListItem.Value before assigning a value to its Text property, both Text and Value end up being set to the same value. It's certainly possible to work around this behavior, but the question remains - why does this happen? ...

Adding text and buttons to the initial image in the slider: a step-by-step guide

I'm facing an issue with my html image slider as I try to add buttons and text to the first image but it keeps getting overridden. <div id="captioned-gallery"> <figure class="slider"> <figure> & ...

Add color to the cells within the table

I need help with dynamically adding colors to my table based on the results. If the result is 'UnSuccessfull', the color should be 'red'. If the result is 'Successful', the color should be 'green'. The challenge I a ...

Eliminate any additional spacing or padding surrounding the text input field

Is there a way to adjust the inner padding of a text field? Currently, when entering text in an HTML text field, there is padding at the beginning and end. The numbers I am inputting have no more than 3 digits, and the current padding takes up about the wi ...

I am facing difficulty importing emotion js style using dynamic variables

I recently designed a webpage that has the following appearance: https://i.stack.imgur.com/AnIXl.jpg Here is the code from my _app.tsx file: import '../styles/globals.css' import type { AppProps } from 'next/app' import { createTheme ...

What is the best way to use .htaccess to maintain $_POST data while consistently eliminating file extensions?

This morning, as I was working on a website, I decided to tackle the task of removing file extensions. Although I am still learning about .htaccess files and their regex, I came across some code online that I thought would help me achieve my goal. The firs ...

Creating a jQuery variable in version 1.9.1 results in an error, whereas in version 1.8.3 it does not succeed

Recently updated to version 1.9.1 and encountered some technical difficulties. Despite that, everything works fine except for one thing: var $newthumbs = $(' <div id=\"car-7\" class=\"thumbnail_car thumbnail span2&bso ...

Is there a way to modify the variable in order to switch the font of the heading every second using CSS and JavaScript?

I'm trying to create a heading that changes fonts every second, but I'm having trouble changing the variable to set it to another font. Check out my code here. Despite watching tutorials, everything seemed too confusing. var root = document.q ...

Issue observed in Angular Material: mat-input does not show background color when in focus mode

https://i.stack.imgur.com/eSODL.png Looking for a solution regarding the mat-input field <mat-form-field> <input class='formulaInput' matInput [(ngModel)]='mathFormulaInput'> </mat-form-field> The blue backg ...