1

I have a web page inside which i have put an iframe. The iframe loads a pdf file after making few calculations. The calculations are carried out from server side code based on parameters which are stored in a hidden variable in the parent page.

this is the parent page html markup

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

The src of the iframe is set dynamically.

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

This is how i try to access the hidden field from the page which is loaded in iframe(PrintPDF.aspx)

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

But i get null everytime.

How shall i get value of hidden field? Or shall i change the way i m fetching the value at server side.

MARKAND Bhatt
  • 2,428
  • 10
  • 47
  • 80

1 Answers1

1

You can pass hidden field values as a query string in your iframe source URL.

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

As discuss with questioner:

Please try below Javascript to get hidden field value in PrintPDF.aspx page.

var getHdnFld = parent.document.getElementById('hdnPrintRo').value;
Keval Gangani
  • 1,326
  • 2
  • 14
  • 28