Saturday, March 24, 2012

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

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 clic
k
the button. Besides, by clicking the button, also close the popup window. Th
e
problem is, when I click the button, the textbox.text is successfully pass t
o
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:270
px;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.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" <Chrysan@.discussions.microsoft.com> wrote in message
news:177F1EBD-C9F1-4794-94AB-3713CFD0CACC@.microsoft.com...
>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:270
px;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.
>
On Wed, 28 Sep 2005 22:47:03 -0700, Chrysan wrote:

> I have a popup window, which consist of a asp:textbox and a asp:button. An
d,
> I would like to pass the textbox.text to the javascript function when I cl
ick
> 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 t
he
> 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:270
px;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
Thanks a lot...it works.
"Onin Tayson" wrote:

> 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 spawnin
g
> of a new window instance.
> HTH,
>
> "Chrysan" <Chrysan@.discussions.microsoft.com> wrote in message
> news:177F1EBD-C9F1-4794-94AB-3713CFD0CACC@.microsoft.com...
>
>

0 comments:

Post a Comment