Sending data through ShowModalDialog by utilizing query strings from ASP.NET code-behind

I am trying to initiate a JavaScript ShowModalDialog from ASP.Net code behind. The code snippet I currently have is as follows:

string _timeSpentinMin = "123";
Page page = HttpContext.Current.CurrentHandler as Page;
ScriptManager.RegisterStartupScript(page, page.GetType(), "OpenModalDialog", "<script type=text/javascript>window.showModalDialog('ClockPopUP.aspx', null, 'dialogWidth:290px;dialogHeight:270px;status:no'); </script>", false);

In addition, I would like to pass a query string to Clock.aspx using JavaScript:

function openmodalWinLunch() {
            var variable1 = "Lunch";
            window.showModalDialog("ClockPopUP.aspx?code=" + variable1, "dialogWidth:290px;dialogHeight:270px,");
        }

My query revolves around how to achieve the same functionality from the ASP.NET code behind. Could you please modify my existing ASP.NET code behind to include passing the string variable _timespentinMin through the query string to the Clock.aspx page when using ShowModalDialog?

Answer №1

Session["TaskActiveNonProd"] = isAnyNonProdTaskActive;
Page currentPage = HttpContext.Current.CurrentHandler as Page;
ScriptManager.RegisterStartupScript(currentPage, currentPage.GetType(), "OpenModalDialog", "<script type=text/javascript>window.showModalDialog('ElapsedClockNonProd.aspx?identifier=" + isAnyNonProdTaskActive.ToString() + "', null, 'dialogWidth:290px;dialogHeight:270px;status:no'); </script>", false);

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

Loading JavaScript and CSS files in an EJS file using Node.js

Here is the structure of my folder: server.js app --routes.js views --ace-builds-master --\src-noconflict --ace.js --index.ejs The 'views' directory contains my ace editor components and my index.ejs file. I am trying to include ac ...

An unexpected identifier error occurred following an Ajax request

Below is the HTML code that I am working with: <div id="texttheory" class="centertext">'. $short .' </div>'; <button id="thbutton" class="theory_button" onclick="javascript:changetheory('.$long.')"> <im ...

Combining the .Net Framework and IIS on a Windows Server 2008 R2 system

While deploying a website using .net framework 4.5 on a 2008r2 server, I encountered a problem. Even though I installed the .Net framework on the box, I couldn't find it anywhere in Server Manager (I checked under features). The system already had .ne ...

The API designed to accept JSON data via a POST request is receiving a different data type than expected

I have a task to develop an API that receives JSON data in NODE.JS via the POST method. To simplify request management, I utilize Express and BodyParser library to handle the body of POST requests. The data is structured in a JavaScript object like this: ...

What is the best way to transform a 2D array into a grid of card components using React JS and Material-UI components?

I have been presented with a 2D array of objects and my task is to transform it into a matrix of cards, where each card will display text retrieved from the object. I have utilized the .map function but faced undesired results when working with the followi ...

Discovering a full class entity within an array using Javascript

I am currently working with an array of objects that serves as the datasource for a materials table. Before adding a new row, I need to ensure that it does not already exist in the array. Since there is no key value assigned to the objects in the array, I ...

Having trouble with ReactJS: Why is this.setState not working?

Hello there, I am currently learning ReactJS and struggling with an issue where I keep getting the error message "this.setState is not a function". constructor() { super(); this.state = { visible: false, navLinesShow: true }; ...

`Switch up the UberMenu main menu icon when a submenu is in use`

Recently, I started using the UberMenu plugin on my WordPress website. Here is a handy guide to an example menu: link. Interestingly, my menu is structured exactly the same way, except that the submenu only opens when clicked rather than hovered over. I ...

Tips for enhancing undo/redo functionality when working with canvas drawings in React

Currently, I am working on implementing undo/redo functionality for html-canvas drawing on medical (.nii) images in a React application. The images consist of slices stored in a Uint8ClampedArray and usually have dimensions around 500 (cols) x 500 (rows) x ...

Attempting to minimize the repetition of code in Redux by implementing some utility functions

Is there a potential issue with the method I'm attempting in this URL: The concept involves altering only the actions file when introducing a new action. One improvement I am considering is recursively merging the status passed from the actions with ...

Searching for an element using Python's Selenium and JavaScript

on this page I am trying to click on the "Choose file" button but I keep getting the error message: javascript error: argument is not defined var1 = sys.argv[1] path = os.path.abspath(var1) driver.get("https://www.virustotal.com/gui/home/upload& ...

Error in Jquery: Unable to locate element with attribute "[data-weight]"

After removing a lot of unnecessary code for better readability, I encountered an error on this line: $('[data-weight]').each(function() { The error message indicates that it is null <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "h ...

Unable to activate the date range picker

I am having trouble with integrating the daterange picker on my webpage. I can't seem to get it to work properly. Can anyone help me figure out what I might be doing wrong or if there's something missing? CSHTML: <div class="has-feedback" &g ...

Developing object instances using AngularJS

Looking for some guidance on creating an object using Angular's factory capabilities since I'm new to AngularJS. Here's the code snippet that I have: angular.module('7minWorkout') .factory('WorkoutPlan', function(args){ ...

Focusing on a particular iframe

I am currently using the "Music" theme from Organic Theme on my WordPress site and have inserted this code to prevent SoundCloud and MixCloud oEmbeds from stretching the page width: iframe, embed { height: 100%; width: 100%; } Although the fitvid ...

Having difficulty choosing an item from a personalized autocomplete search bar in my Vue.js/Vuetify.js project

NOTE: I have opted not to use v-autocomplete or v-combobox due to their limitations in meeting my specific requirements. I'm facing difficulties while setting up an autocomplete search bar. The search functionality works perfectly except for one mino ...

Prevent background element from being selected with a double-click

Whenever I double-click on the background, the first element gets selected. How can I prevent this from happening? Here is a fiddle to demonstrate: https://jsfiddle.net/cb6fjr7n/1/ <input style="text" value="lala"/> If you double-click outside of ...

Is there a way to view Deno's transpiled JavaScript code while coding in TypeScript?

As I dive into Typescript with Deno, I am curious about how to view the JavaScript result. Are there any command line options that I may have overlooked in the documentation? P.S. I understand that Deno does not require a compilation step, but ultimately ...

What is the method to invoke a function within a factory in angularjs by using a string parameter?

I have a complex logic that I want to encapsulate in an AngularJS factory for easy use with dependency injection. The challenge is that the logic is dynamic, so I don't know in advance what functions will be available. What I have is a string represen ...

What is the best way to invoke a function only once in typescript?

Struggling to implement TypeScript in React Native for fetching an API on screen load? I've been facing a tough time with it, especially when trying to call the function only once without using timeouts. Here's my current approach, but it's ...