?
Solved

Popup window inside update panel

Posted on 2009-02-16
10
Medium Priority
?
6,124 Views
Last Modified: 2013-12-17
Hi All,
I have an aspx page with ajax controls and code behind page. I am using a java script for open a popup window from code behind. This is working fine. But I want to open this window inside the update panel rather than open as a new window. I want to use this popup window repeatedly. So I can't use Model Popup control. Here is the code.


ASPX
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
                <asp:UpdatePanel ID="UP1" runat="server">
                    <ContentTemplate>
                        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    
                        <Triggers>
                            <asp:PostBackTrigger ControlID="Button1" />
                        </Triggers>        
                    </ContentTemplate> 
                </asp:UpdatePanel>
            </div>
    </form>
 
CODE BEHIND
            if(Page.IsPostBack){
                 System.Text.StringBuilder sb = new System.Text.StringBuilder();
                 sb.Append(@"<script language='javascript'>");
                 sb.Append(@"newwin=window.open 'WebForm1.aspx','Console','width=300,height=100,resizable=no');");
                 sb.Append(@"</script>");
                 ScriptManager.RegisterStartupScript(this.UP1, UP1.GetType(), "controlJSScript", sb.ToString(), false);
            }

Open in new window

0
Comment
Question by:danushka_l
  • 5
  • 4
9 Comments
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23649386
I assume you want to use IFrames.  But what is the purpose of use it inside an update panel?  Do you have the src (web page) different each time?
0
 

Author Comment

by:danushka_l
ID: 23649423
Hi,
I want to open the popup window as a child window and disable the parent window. It's like when you use model popup control the panel comes to front and background goes to gray and disabled. I hope you got what I want
0
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23649530
ok, here is the code.

And in WebForm1.aspx, add this code.
<base target="_self"/>

If you want to use the ModalPopupExtender, refer
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string features = "dialogHeight:100px;"
        + "dialogWidth:300px;center:yes;edge:raised;"
        + "help:no;resizable:no;scroll:yes;status:no;";
string target = getLoc + "WebForm1.aspx?";
string url = target + "&rndAvoidCache=" + Math.random(); //avoid cache
sb.Append(@"window.showModalDialog('" + url + "','','" + features + "');");
Page.ClientScript.RegisterStartupScript(Page.GetType(), "controlJSScript", sb.ToString(), true);

Open in new window

0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:danushka_l
ID: 23656126
Hi,
I am getting two errors. Pls look into this. Thanks

The name 'getLoc' does not exist in the current context
'System.Math' does not contain a definition for 'random'
0
 
LVL 12

Accepted Solution

by:
CB_Thirumalai earned 200 total points
ID: 23656439
Sorry, try this
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string features = "dialogHeight:100px;"
        + "dialogWidth:300px;center:yes;edge:raised;"
        + "help:no;resizable:no;scroll:yes;status:no;";
string target = "WebForm1.aspx?";
sb.Append(@"window.showModalDialog('" + target + "','','" + features + "');");
Page.ClientScript.RegisterStartupScript(Page.GetType(), "controlJSScript", sb.ToString(), true);

Open in new window

0
 

Author Comment

by:danushka_l
ID: 23678858
Hi Thank for the reply. It works. But the problem is with javascripts. Can we user ModelPopupExtender for this. Without having the popup panel in the parent window can we call a seperate aspx as window.showdialog. I saw an artical using a user control. Can we use a popup user control for this and call it inside the update panel like ModelPopupExtender.

Thank you
0
 

Author Comment

by:danushka_l
ID: 23679110
Hi,
I got what I want. I create a usercontrol with ModelPopupExtender and register with the parent page. Now I can call it any where I want.

Thank you for your support
0
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23680472
That is up to the wish and requirement of the developer to that.  Happy to know, If my solution has helped you in fixing this.
0
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23728649
I have given him a solution to use the Modal popup window as well as the AJAX Modal popup extender.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question