Pass parameter to Popup window

D

dyw55a

I have 2 webform in vb.NET application.
On Webform1, I have one text box1 and one button.
on Webform2, I have one text box .
I need transfer the value of textbox 1 in webform1 to textbox2 in
webform2. and popup webform2 when user click on the button on webform1.

I have code in webform1:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
End Sub

and following code in webform2:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = Request("a").ToString
End Sub


I could not get the result unless I click on the button1 twice. i know
what happen in here but have no solution. I will be appreciated if you
could help here.

Thanks in advanced,
Di
 
G

Guest

Hi ,
You can achieve this by injecting a javascript in the Button1 click
event on the server side . Write an function to inject an javascript in the
webform1 button1 click.
Don't do anything with Attributes of button1 as it won't achieve result u
requires as the 1st page the textbox1 value would be blank.



private void openWindowInjectScript(){
string myScript;
myScript = "<scr" + "ipt>window.open('WebForm2.aspx?a=" + txtIdfield.Value
+ "',null,'height=250, width=250,status= no,resizable= no, scrollbars=no,
toolbar=no,location=no,menubar=no'); </scr" + "ipt>";
this.Page.RegisterStartupScript("JavaScript",myScript);
}

In the webform1.aspx button1_Click event
private void Button1_Click(object sender, System.EventArgs e)
{
openWindowInjectScript();
}
Basically openwindowInjectScript register a script at pageload and which
will make to open an window with current values.

This is the way out for it and it should work


Regards
IntelYogi
 
D

dyw55a

Thank you for your reply. But actually I tried and this did not work
for some reason, any idea?
 
A

Amar

Try this onClick event of your button

Response.Write("<SCRIPT>");
Response.Write("window.open('page,aspx?value=" + myval +
"',null,'height=200,width=900,status=yes,toolbar=no,menubar=no,location=no');
");
Response.Write("</SCRIPT>");

I think this will do the trick, tell me if not
 

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

Top