Link to home
Start Free TrialLog in
Avatar of danushka_l
danushka_l

asked on

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

Avatar of CB_Thirumalai
CB_Thirumalai
Flag of India image

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?
Avatar of danushka_l
danushka_l

ASKER

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
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

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'
ASKER CERTIFIED SOLUTION
Avatar of CB_Thirumalai
CB_Thirumalai
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
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.
I have given him a solution to use the Modal popup window as well as the AJAX Modal popup extender.