We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Multiple dialogs from server-side

Hi friends,

I´m trying  to create and open some dialogs in code-behind using this code: (and I´m planning to use it inside a menu to open some more dialogs...)

ASPX
<form id="form1" runat="server">
       <asp:ScriptManager runat="server" ID="aspScriptManager1" />
       <asp:UpdatePanel ID="up1" runat="server">
           <ContentTemplate>
               <div runat="server" id="div2" class="control"/>
               <ej:Button ID="Button1" runat="server" Type="Button" Text="Open window 1" Size="Normal" OnClick="openWindow1" ShowRoundedCorner="true" />
               <ej:Button ID="Button2" runat="server" Type="Button" Text="Open window 2" Size="Normal" OnClick="openWindow2" ShowRoundedCorner="true" />
           ContentTemplate>
       asp:UpdatePanel>
   form>
SERVER SIDE
protected void openWindow1(object Sender, Syncfusion.JavaScript.Web.ButtonEventArgs e)
{
    Syncfusion.JavaScript.Web.Dialog test1 = new Syncfusion.JavaScript.Web.Dialog();
 
    test1.ShowOnInit = true;
    test1.IsResponsive = true;
    test1.Title = "Window 1 - " + DateTime.Now.ToString("hh:mm:ss");
    test1.ID = "win1_" + DateTime.Now.ToString("hhmmss");
    test1.ContentUrl = "page1.aspx";
    test1.ContentType = "iframe";
    div2.Controls.Add(test1);
}
protected void openWindow2(object Sender, Syncfusion.JavaScript.Web.ButtonEventArgs e)
{
    Syncfusion.JavaScript.Web.Dialog test2 = new Syncfusion.JavaScript.Web.Dialog();
 
    test2.ShowOnInit = true;
    test2.IsResponsive = true;
    test2.Title = "Window 2 - " + DateTime.Now.ToString("hh:mm:ss");
    test2.ID = "win2_" + DateTime.Now.ToString("hhmmss");
    test2.ContentUrl = "page2.aspx";
    test2.ContentType = "iframe";
    div2.Controls.Add(test2);
}
When "openWindow1" is fired, a new dialog will open as expected, but as soon as you fire "openDialog2", the code is executed as expected but a dialog with the same title and content of "window1" is shown!! (please, see image attached)

Could you, please, give me some clue of what is wrong here?

What I want to achieve is: Create a menu with some options that will open several dialogs. Each dialog will have different content, title, etc without reloading entire page.

Thanks in advance.




Attachment: image1_6126eaf2.rar

3 Replies

DL Deepa Loganathan Syncfusion Team March 25, 2019 12:35 PM UTC

 
Hi Fabio,  
 
Greetings from Syncfusion support.  
 
We have checked the reported issue while creating Dialog dynamically from Codebehind upon button click and were able to reproduce it while using a common container for creating Dialog. This was because, same div element is used as a wrapper for rendering both the Dialogs and so the same instance is maintained for both the Dialogs. 
 
To overcome this issue, we suggest using separate containers for rendering Dialogs as given in the below code.  
 
[ASPX] 
 
<div runat="server" id="container" class="control"> 
   <div runat="server" id="dialog1"></div> 
   <div runat="server" id="dialog2"></div> 
</div> 
 
 
[ASPX.CS] 
 
public partial class DialogFeatures : System.Web.UI.Page 
    { 
        Syncfusion.JavaScript.Web.Dialog test1 = new Syncfusion.JavaScript.Web.Dialog(); 
        Syncfusion.JavaScript.Web.Dialog test2 = new Syncfusion.JavaScript.Web.Dialog(); 
 
        protected void Page_Load(object sender, EventArgs e) 
        { 
        } 
        protected void openWindow1(object Sender, Syncfusion.JavaScript.Web.ButtonEventArgs e) 
        { 
            test1.ShowOnInit = true; 
            test1.IsResponsive = true; 
            test1.Title = "Window 1 - " + DateTime.Now.ToString("hh:mm:ss"); 
            test1.ID = "win1_" + DateTime.Now.ToString("hhmmss"); 
            test1.ContentUrl = "Page1.aspx"; 
            test1.ContentType = "iframe"; 
            dialog1.Controls.Add(test1); 
            container.Controls.Add(dialog1); 
 
        } 
        protected void openWindow2(object Sender, Syncfusion.JavaScript.Web.ButtonEventArgs e) 
        { 
            test2.ShowOnInit = true; 
            test2.IsResponsive = true; 
            test2.Title = "Window 2 - " + DateTime.Now.ToString("hh:mm:ss"); 
            test2.ID = "win2_" + DateTime.Now.ToString("hhmmss"); 
            test2.ContentUrl = "Page2.aspx"; 
            test2.ContentType = "iframe"; 
            test2.ClientSideOnCreate = "Oncreate"; 
            dialog2.Controls.Add(test2); 
            container.Controls.Add(dialog2); 
 
        } 
    } 
 
 
We have attached a sample for your reference in the below link. Please check and get back to us if you would require any further assistance.  
 
Sample:  
 
Regards,  
Deepa L. 



FM Fabio Marcos Euzebio April 8, 2019 01:23 PM UTC

Thank you !!

Regasds.


PO Prince Oliver Syncfusion Team April 9, 2019 04:50 AM UTC

Hi Fabio,

Most welcome. Let us know if you need any further assistance on this.

Regards,
Prince

Loader.
Live Chat Icon For mobile
Up arrow icon