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
 
Joined
Aug 30, 2006
Messages
7
Reaction score
0
This works for me....

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",myScr ipt);
}

In the webform1.aspx button1_Click event
private void Button1_Click(object sender, System.EventArgs e)
{
openWindowInjectScript();
}

but then I need to pass two values.....txtIdfield.Value and txtNameField.Value....


So how owuld i do it?
 
Joined
Aug 30, 2006
Messages
7
Reaction score
0
I was able to solve my problem of passing two values to the child page....

Here's what i did....



***********************************************
For the MainPage.aspx......I have the following codes
***********************************************


Private Sub cmdSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSelect.Click

openWindowInjectScript()

End Sub



Private Sub openWindowInjectScript()

Dim myScript As String

myScript = "<script>window.open('PopPage.aspx?a=" + txtIdfield.Text + ";" + txtNameField.Text + "', null,'height=250, width=772,status= no,resizable=yes, scrollbars=no, toolbar=no,location=no,menubar=no'); </script>"

Page.RegisterStartupScript("JavaScript", myScript)

End Sub




*******************************************************
For the child Page, the PopPage.aspx....i have the following codes
*******************************************************



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If (Not Page.IsPostBack) Then
'a is a value from the parent page
Dim strIDName As String = Request("a").ToString

Dim str As String = strIDName
Dim str2 As String = strIDName
Dim strTemp As String

Dim SemicolonPos As Integer = str.IndexOf(";")

'Check for the semicolon
If SemicolonPos > 0 Then

'remove all other characters after the semicolon
strTemp = str.Remove(SemicolonPos, (str.Length - SemicolonPos))

'get all characters after the semicolon
str2 = str2.Substring(strTemp.Length + 1)

End If

txtUserID.Text = strTemp
txtUserNAme.Text = str2

End If

End Sub
 
Joined
Nov 7, 2006
Messages
1
Reaction score
0
Help

Hi
I am using ASP.net and am using calendar as a popup page name as (calendar.aspx). I want to get the selected date on my previous page in my textbox.
So, how can i do that.

Please help
Thanx in advance
 
Joined
Mar 7, 2007
Messages
2
Reaction score
0
Amar said:
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

(e-mail address removed) wrote in message news:<[email protected]>...
> Thank you for your reply. But actually I tried and this did not work
> for some reason, any idea?

this will work surely i have tried this thanks for saving me to submit the tast intime .
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top