Why popup window will be re-opened again after closing it?

G

Guest

I have a popup window, which consist of a asp:textbox and a asp:button. And,
I would like to pass the textbox.text to the javascript function when I click
the button. Besides, by clicking the button, also close the popup window. The
problem is, when I click the button, the textbox.text is successfully pass to
the javascript function and the popup window will be closed, but the popup
window will be opened again in maximize mode. I notice that, after I add the
line 'Me.btnOK.Attributes.Add...' in my Page_Load event, this thing only
happen. Why is it so?

Please help...thanks.

FYI, the following is my page_load code in code-behind:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.btnOK.Attributes.Add("onclick", "Done('" &
txtConnectionString.Text & "');")
End Sub


The following is my html code:

<script language="javascript">
function Done(strConnectionString) { alert(strConnectionString);
window.close();
}
</script>


Following is the javascript function's code in parent page to call the
popup-dialog window:
<script language="javascript">
function OpenConnectCubeDialog() {
var ParmA;
var ParmB;
var MyArgs = new Array("", "");
var WinSettings =
"center:yes;resizable:no;dialogHeight:270px;dialogWidth:311px;";
var MyArgs = window.showModalDialog("/ModalDialog/ConnectToCube.aspx",
MyArgs, WinSettings);
if (MyArgs != null) {
ParmA = MyArgs[0].toString();
ParmB = MyArgs[1].toString();
initializePivotTable(ParmA, ParmB);
}
}
</script>

Thanks.
 
O

Onin Tayson

Hi Chrysan,

This is a common problem with popup windows... Add the code below to your
..aspx file between the <HEAD></HEAD> tags...

<base target="_self">

This will cause the popup window to post to itself and prevent the spawning
of a new window instance.

HTH,
 
I

intrader

I have a popup window, which consist of a asp:textbox and a asp:button. And,
I would like to pass the textbox.text to the javascript function when I click
the button. Besides, by clicking the button, also close the popup window. The
problem is, when I click the button, the textbox.text is successfully pass to
the javascript function and the popup window will be closed, but the popup
window will be opened again in maximize mode. I notice that, after I add the
line 'Me.btnOK.Attributes.Add...' in my Page_Load event, this thing only
happen. Why is it so?

Please help...thanks.

FYI, the following is my page_load code in code-behind:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.btnOK.Attributes.Add("onclick", "Done('" &
txtConnectionString.Text & "');")
End Sub


The following is my html code:

<script language="javascript">
function Done(strConnectionString) { alert(strConnectionString);
window.close();
}
</script>


Following is the javascript function's code in parent page to call the
popup-dialog window:
<script language="javascript">
function OpenConnectCubeDialog() {
var ParmA;
var ParmB;
var MyArgs = new Array("", "");
var WinSettings =
"center:yes;resizable:no;dialogHeight:270px;dialogWidth:311px;";
var MyArgs = window.showModalDialog("/ModalDialog/ConnectToCube.aspx",
MyArgs, WinSettings);
if (MyArgs != null) {
ParmA = MyArgs[0].toString();
ParmB = MyArgs[1].toString();
initializePivotTable(ParmA, ParmB);
}
}
</script>

Thanks.
It looks to me that we are mixing server-side/client-side concepts here.
The popup window's will open a completely independent window; it
javascript event code for the button must also be output by the same asp
that you are generating for the info you are displaying.
I hope this is clear
 
G

Guest

Thanks a lot...it works.

Onin Tayson said:
Hi Chrysan,

This is a common problem with popup windows... Add the code below to your
..aspx file between the <HEAD></HEAD> tags...

<base target="_self">

This will cause the popup window to post to itself and prevent the spawning
of a new window instance.

HTH,


Chrysan said:
I have a popup window, which consist of a asp:textbox and a asp:button.
And,
I would like to pass the textbox.text to the javascript function when I
click
the button. Besides, by clicking the button, also close the popup window.
The
problem is, when I click the button, the textbox.text is successfully pass
to
the javascript function and the popup window will be closed, but the popup
window will be opened again in maximize mode. I notice that, after I add
the
line 'Me.btnOK.Attributes.Add...' in my Page_Load event, this thing only
happen. Why is it so?

Please help...thanks.

FYI, the following is my page_load code in code-behind:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.btnOK.Attributes.Add("onclick", "Done('" &
txtConnectionString.Text & "');")
End Sub


The following is my html code:

<script language="javascript">
function Done(strConnectionString) { alert(strConnectionString);
window.close();
}
</script>


Following is the javascript function's code in parent page to call the
popup-dialog window:
<script language="javascript">
function OpenConnectCubeDialog() {
var ParmA;
var ParmB;
var MyArgs = new Array("", "");
var WinSettings =
"center:yes;resizable:no;dialogHeight:270px;dialogWidth:311px;";
var MyArgs = window.showModalDialog("/ModalDialog/ConnectToCube.aspx",
MyArgs, WinSettings);
if (MyArgs != null) {
ParmA = MyArgs[0].toString();
ParmB = MyArgs[1].toString();
initializePivotTable(ParmA, ParmB);
}
}
</script>

Thanks.
 

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,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top