Category / Section
How to trigger server-side events for controls inside Dialog?
1 min read
Description
Controls when placed inside Dialog box cannot be bound to their server-side events. Since the Dialog control is rendered outside the Form element, the corresponding server-side events are not triggered.
Solution
To trigger the server-side events for any control inside the Dialog control, you have to configure the Content property of the Dialog. Set the Content property value to the corresponding Form’s ID, so that the controls inside Dialog can bind to their server-side events. Otherwise Dialog is rendered outside the Form and does not trigger events or validate the fields.
RAZOR
<form id="form1" runat="server"> <asp:ScriptManager runat="server"></asp:ScriptManager> <ej:Dialog ID="lognForm" runat="server" ShowOnInit="true" Content="#form1"> <DialogContent> <p>Your content here</p><br /> <ej:Button ID="ejbtn" runat="server" Type="Button" Text="EJ Click" OnClick="ejbtn_Click"></ej:Button> </DialogContent> </ej:Dialog> </form>
C#
protected void ejbtn_Click(object Sender, Syncfusion.JavaScript.Web.ButtonEventArgs e) { //Your function here }