How to show/open Dialog from code behind?

How to show/open Dialog from code behind?

1 Reply

BS Buvana Sathasivam Syncfusion Team February 19, 2018 05:55 AM UTC

Hi knjayGmail,   
  
Thanks for using Syncfusion Products.   
  
We have rendered dialog control.  In the initial rendering of dialog control, we have set showOnInit as false using code behind.  Please find the below code.   
Default.aspx   
  
<ej:Dialog ID="dialog" Title="Dialog" runat="server">   
   
        <DialogContent>   
            <p>This is a Dialog</p>   
        </DialogContent>   
   
    </ej:Dialog>    
  
Default.aspx.cs   
  
  protected void Page_Load(object sender, EventArgs e)   
        {   
            this.dialog.ShowOnInit = false;   // Initially, dialog is hide state   
        }   
  
We have created one button with server side, click event handler.  If you click the button, post back occurs and set in server-side dialog showOnInit properties.  Using this property, we have shown the dialog control when you click the button.  Please find the below code.   
  
Default.aspx   
  
<ej:Button ID="ejbtn" runat="server" Type="Button" Text="Click to open dialog using code behind" OnClick="ejbtn_Click"></ej:Button>      
  
Default.aspx.cs   
  
protected void ejbtn_Click(object Sender, Syncfusion.JavaScript.Web.ButtonEventArgs e)   
        {   
            this.dialog.ShowOnInit = true;  // Set dialog as open    
        }   
  
  
    
  
Regards,   
Buvana S   
 


Loader.
Up arrow icon