How to get HtmlInputHidden value in a popup window?

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

In page1:<INPUT id="MD" type="hidden" name="MD" value="Hello world">,
and there is a button, has a javascript onclick event, in this event, a
popup window will appear.

In the pop-up window, how can I get the hidden control's value (Hello
world) in code behind?
BTW, I can get it in clicent by:
var MDValue = window.opener.document.getElementById("MD").value;
 
You have to pass that as a querystring parameter to the popup, then the
code-behind can access it.
 
I know I can access via querystring, but what I need is:
The page can only be opened in my way, never display information if
user input the link in the addressbar, then click "enter".
 
For the popup to be the information, the accepted way is to use the
querystring. A popup is nothing more than a page, and there is little you
can do to prevent the user from loading it manually.

Now, if you want to be tricky, you could always do a postback for your
button and then use something like RegisterStartupScript to inject the
showModelDialog function. This way you can store the field value in a
session variable and use this to verify they came from the correct place.
You can also check the Referer header field to make sure they came from your
page.
 
The 2 sites are different, Session doesn't work in this case.
I'm using javascript to control it,
if( window.opener == null )
// window.location = "xxxx";

but it isn't safe anyway.
 
Back
Top