How to get HtmlInputHidden value in a popup window?

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;
 
P

Peter Rilling

You have to pass that as a querystring parameter to the popup, then the
code-behind can access it.
 
J

Jack

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".
 
P

Peter Rilling

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.
 
J

Jack

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top