popup window with postback...

E

EMW

Hi,

Is it possible with VB.NET and Javascript to popup a window, after a
buttonclick, in which the user writes some text in a textbox and then when
that window is closed with a button, the text is posted back to the aspx
program?

If it is possible, please let me know some articles about this?

thanks,
Eric
 
C

Cliff Harris

I've done somthing similar with a selection pop-up box.
I use javascript on my main form to open a popup box. Then, when the user
selects their option, I use javasrcript to access a textbox on my parent
form, insert the text, then also use javascript to fire then postback event
on the main form, passing it the name of a submit button so any associated
events can be fired.
To access the controls on the parent form, I used:
window.opener.document.all.textboxname.value
and
window.opener.__doPostBack('buttonname', '')

I made the javascript dynamic as well... here is the javascript I created
for the popup window

// register javascript
if(!Page.IsClientScriptBlockRegistered("fillAndClose"))
{
string script = @"<script language=""javascript"">" + "\r\n";
script += "function fillAndClose(empid){\r\n";
script += "window.opener.document.all." +
Request.QueryString["textbox"] + ".value=empid;\r\n";
script += "window.opener.__doPostBack('" +
Request.QueryString["button"] + "','');\r\n";
script += "window.close();}\r\n";
script += "</script>\r\n";
this.Page.RegisterClientScriptBlock("fillAndClose", script);
}

So, if I just pass in the name of the textbox and the name of the button in
a querystring, the popup window will use those on the main form.

HTH,
-Cliff
 
E

EMW

Thanks!

rg,
Eric


Cliff Harris said:
I've done somthing similar with a selection pop-up box.
I use javascript on my main form to open a popup box. Then, when the user
selects their option, I use javasrcript to access a textbox on my parent
form, insert the text, then also use javascript to fire then postback event
on the main form, passing it the name of a submit button so any associated
events can be fired.
To access the controls on the parent form, I used:
window.opener.document.all.textboxname.value
and
window.opener.__doPostBack('buttonname', '')

I made the javascript dynamic as well... here is the javascript I created
for the popup window

// register javascript
if(!Page.IsClientScriptBlockRegistered("fillAndClose"))
{
string script = @"<script language=""javascript"">" + "\r\n";
script += "function fillAndClose(empid){\r\n";
script += "window.opener.document.all." +
Request.QueryString["textbox"] + ".value=empid;\r\n";
script += "window.opener.__doPostBack('" +
Request.QueryString["button"] + "','');\r\n";
script += "window.close();}\r\n";
script += "</script>\r\n";
this.Page.RegisterClientScriptBlock("fillAndClose", script);
}

So, if I just pass in the name of the textbox and the name of the button in
a querystring, the popup window will use those on the main form.

HTH,
-Cliff

EMW said:
Hi,

Is it possible with VB.NET and Javascript to popup a window, after a
buttonclick, in which the user writes some text in a textbox and then when
that window is closed with a button, the text is posted back to the aspx
program?

If it is possible, please let me know some articles about this?

thanks,
Eric
 
E

Eliyahu Goldin

Eric,

You can popup a window with javascript call showModalDialog(...). You can
pass a url of a aspx page as a parameter. You will get a new window with a
fully functional webform inside. It can include all server- and client-side
components, perform postbacks, whatever you want. The calling window will
sit and wait until the popup closes. It will get back a parameter, which can
be the text you want to pass.

Eliyahu
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top