Post data to a new popup window without using hidden input fields

24,000

Solution 1

A hidden form is the standard approach to this. I don't recall if the following has complications, but you may even be able to create the form on the fly and submit it. In my opinion, there's nothing wrong with this approach. Another possibility is to use jQuery.post() and in the callback function open a new window and paste the returned content. For example,

var win = window.open();
win.document.write(returnedContent);

Solution 2

eureka! this test works:

function postData() {           
        $.post('popup.aspx', { text1: "aaa", text2: "bbb" }, function (result) {
            WinId = window.open('', 'newwin', 'width=400,height=500');
            WinId.document.open();
            WinId.document.write(result);
            WinId.document.close();
        });
    }

on popup.aspx.cs

test1.Text = Request["text1"];
test2.Text = Request["text2"];

on popup.aspx

<asp:Label ID= "test1" runat="server"></asp:Label>
<asp:Label ID= "test2" runat="server"></asp:Label>
Share:
24,000

Related videos on Youtube

bcm
Author by

bcm

Updated on July 20, 2020

Comments

  • bcm
    bcm almost 4 years

    Is it possible to post data to a new window without using hidden input fields. Data can be possibly quite large. Looking at something similar to jQuery ajax type post.. except I need to post the data to a new page.

  • bcm
    bcm almost 14 years
    upon success, it just returns to the same window doing the post. what i need is for the data to be posted to 'PAGE x' and stay on 'PAGE x' where 'PAGE x' is a popup (new window).
  • TNi
    TNi almost 14 years
    How did you open Page X in the first place? If it was with JavaScript on the same page as the one from which you are doing the post, you may still be able to use the second method mentioned. Otherwise, I'm not aware of any way other than with a hidden form (there's a reason it's standard).
  • bcm
    bcm almost 14 years
    That would be part of my question. If you are not aware of anyway (as I am)... will wait for someone who has the answer.
  • TNi
    TNi almost 14 years
    That's fine, and I would welcome any news on this. Because I don't know everything, I always keep open the possibility that I've missed something. However, only bear in mind that it is very likely that there just isn't a way to accomplish what you want in the way you want.
  • TNi
    TNi almost 14 years
    I just checked up on this. I may be wrong, but this solution appears to be a refined version of exactly what I suggested, or did I misunderstand your original comments?
  • Arman Bimatov
    Arman Bimatov over 10 years
    Submitting a hidden form in target="_blank" would result in a blocked popup.

Related