Popup window inside update panel

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

danushka_lAsked:
Who is Participating?
 
CB_ThirumalaiCommented:
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
 
CB_ThirumalaiCommented:
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
 
danushka_lAuthor Commented:
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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
CB_ThirumalaiCommented:
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
 
danushka_lAuthor Commented:
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
 
danushka_lAuthor Commented:
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
 
danushka_lAuthor Commented:
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
 
CB_ThirumalaiCommented:
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
 
CB_ThirumalaiCommented:
I have given him a solution to use the Modal popup window as well as the AJAX Modal popup extender.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.