Access the hidden variable data of the parent page within a child iframe

I have a webpage with an embedded iframe that loads a PDF file after performing calculations. These calculations are done on the server side based on parameters stored in a hidden variable on the parent page.

Here is the HTML markup of the parent page:

    <iframe style="width:100%; height:100%;" id="iPdf"></iframe>
    <input type="hidden" id="hdnPrintRo" name="hdnPrintRo" value="1" />

The source of the iframe is set dynamically.

 $('#iPreRoPDf').attr('src', "PrintPDF.aspx?printid=" + printGuid);

This is how I attempt to access the hidden field from the page loaded in the iframe (PrintPDF.aspx):

string a = Request.Form["hdnField"];

However, I always receive a null value.

How can I retrieve the value of the hidden field? Should I change the way I am accessing the value on the server side?

Answer №1

If you need to pass hidden field values to an iframe source URL, you can do so by adding them to the query string.

$('#iPreRoPDf').attr('src', "PrintPDF.aspx?printid=" + printGuid + "&PrintRo=" + $('#hdnPrintRo').val());

After discussing with the asker:

Here is a Javascript snippet that can help you retrieve the hidden field value in the PrintPDF.aspx page:

var getHdnFld = parent.document.getElementById('hdnPrintRo').value;

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

What is the best way to incorporate tooltips in SVG?

My teacher wants me to display a tooltip on an SVG circle with links and information when we hover over it. They suggested using jQuery UI, but I've done extensive research and nothing has been able to assist me so far. ...

Issues Plaguing My Asynchronous JavaScript Implementation

class FileChecker { constructor() { this.arguments = process.argv.splice(2); this.fileToCheck = this.arguments[0]; this.directoryToSearch = this.arguments[1] ? this.arguments[1] : ''; this.currentDirectory = p ...

Step-by-step guide on how to showcase elements within v-for by clicking on them

In my data array, only the first element is visible by default. Clicking on either the YES or NO button will display the element with the corresponding id of yes_section or no_section (depending on which button was clicked). For instance, if we click on ...

Is it possible to execute my tests while using incognito mode?

Currently, the solution I'm testing automatically saves the login information, causing my tests to fail when opening a new browser. Even browser.Dispose() doesn't resolve this issue. It seems like testing in incognito mode would be more reliable, ...

What is the best way to extract the ID of an element that triggers an OnChange event?

Just a heads up: The solution to my problem ended up being CSS code that was triggered by clicking on a widget. Once I realized it was CSS, along with the widget name and hover action, I was able to handle it successfully. Previous question before the PS ...

What could be the reason why I am unable to load the ejs file?

https://i.stack.imgur.com/91bPg.png Issue: Unable to find the "index.ejs" view in the views directory ...

Shift the sleek navigation arrows to the interior of the slides

Is there a way to relocate the navigation arrows on the slider images? I have tried various methods found online with no success. Currently using ASP.NET, but doubt it matters. Employing the latest version of SLICK. Here is the HTML code snippet: <%@ ...

Using JQuery's change function with a Button Group is a great way

I encountered an issue where my button group works with the on.click function but not with on.change. <div class="ui buttons"> <button class="ui button">Value 1</button> <button class="ui bu ...

Trigger a jQuery event when an element is moved to a new line

Is there a way to trigger a jQuery event when an element moves to a new line in the view? I want to hide navigation items and run additional JavaScript code when this happens. Any ideas on how to achieve this? Here's how my navigation appears in a wi ...

Providing optimal image dimensions based on the size of the viewing window

In the process of creating an image hosting website, I have taken on the challenge to familiarize myself with different programming languages such as PHP, MySQL, HTML, CSS, and JavaScript. Currently, the website loads full-size images and resizes them to ...

Is it possible to exclude specific URLs from CSRF protection in sails.js?

I am currently integrating Stripe with my sails.js server and need to disable CSRF for specific URLs in order to utilize Stripe's webhooks effectively. Is there a way to exempt certain URLs from CSRF POST requirements within sails.js? I have searched ...

Adding a <link> tag with a specific onload attribute in the <head> using Next.js

While working on a Next.js project, I am trying to include the following HTML content within the <head>: <link href="..." rel="stylesheet" media="print" onload="this.media='all'" /> The code I ...

The child div can be scrolled horizontally, while the parent window remains fixed

I am facing a challenge with my HTML and CSS setup. I want to create a child div that scrolls horizontally, but I do not want the parent window to scroll along with it. Below is my current code: <div id="parent"> <div id="div1"> . ...

The QR Code has a hidden trick up its sleeve in WPF - a TAB command that seamlessly shifts focus

Recently, I developed a program that utilizes a Powerscan PD9530 scanner to record serial numbers of various parts into a database. However, one of the parts has TABs within the serial number, causing issues with inputting the entire serial number into a d ...

Merge the data from various sections of a JSON object into a unified array

Upon completing an ajax call to a specific URL, I receive data in the form of a JSON object structured like this: {"field1":["val1","val2","val3",...,"valn"], "field2":["vala","valb","valc",...,"valx"]} My goal is to merge the values of field1 and field ...

Selenium WebDriver Ordered Tests fail to proceed past the first test as ChomeDriver terminates prematurely

After setting up an automation framework and creating individual Unit Tests for each test to run, the team decided to run multiple tests in a specific order during their smoke test using an Ordered Test. However, running these Ordered Tests resulted in an ...

Using a JSON file as a database for a project featuring HTML, CSS, and Vanilla JavaScript

Our task was to create a project that exclusively utilized JSON files for data storage. The data structure we were working with resembles the following: [ { "aircraftName": "Boeing 747", "departDate": 1640173020000, ...

Implement Dynamic Filters in a Vue Component

How can filters be programmatically applied to select values? During each iteration of records and columns, I am checking if the column ID starts with 'd', indicating it's a datetime field. In such cases, I want to apply the humanize filter ...

Send the 'key' parameter to the React component

Attempting to pass a parameter named "key" to a react component is resulting in it not functioning properly. However, when I use "keyy" instead of "key," it works as intended. It appears that using "key" as a parameter name may be causing issues due to it ...

"Experience the power of Vue.js 3 and vue-router as the @click event seamlessly refreshes the entire

Just getting started with Vue and I'm trying to figure out how to toggle the menu open/close on mobile navigation without causing the whole page to reload. Any suggestions on how to prevent that? Here's my code: <router-link to="/ " @click="t ...