How to dynamically set/change ContentUrl before opening Dialog?

Hello

Is it possible to set or change ContentUrl property before opening Dialog? I have tried to set a different url in the BeforeOpen event, but it doesn't work.
Something like this:

@{Html.EJ()
.Dialog("addDialog")
.Title("Dialog")
.ShowOnInit(false)
.ContentType("ajax")
.ContentUrl("/index.html") // this works
.ClientSideEvents(e => e.BeforeOpen("onBeforeDialogOpen"))
.Render();
}

function onBeforeDialogOpen(sender) {
sender.model.contentUrl = "http://localhost:63659/index2.html"; // this does not
}

Thanks, Tom

Update: From this demo:
https://aspdotnetcore.syncfusion.com/Dialog/AjaxContent#/material
it seems that it's possible to load content using ajax, but I can't make it work with ASP.NET MVC Dialog.

3 Replies

AP Arun Palaniyandi Syncfusion Team March 22, 2018 09:09 AM UTC

Hi Tomislav, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your shared codes and to overcome this issue we suggest you to change the contentUrl through the setModel instead of changing via model. Please find the below code snippet. 
 
 
<script> 
 
 
    function onBeforeDialogOpen(e) { 
 
        $("#addDialog").ejDialog({ contentUrl: "http://localhost:62007/api/Orders" });  //use set model to update the contentUrl property 
 
    } 
 
</script> 
 
 
We have also prepared a sample below for your reference. 
 
 
 
Let us know if you have any further queries.  
 
 
Regards, 
Arun P. 




TT Tomislav Tustonic March 23, 2018 08:45 PM UTC

Thanks

This works OK

Cheers,
Tom


BS Buvana Sathasivam Syncfusion Team March 26, 2018 05:11 AM UTC

Hi Tomislav,  
  
Thanks for your update.  We are glad to know that your problem is solved.  Please let us know if you need any assistances, we will be happy to assist you.  
  
Regards,  
Buvana S  
 


Loader.
Up arrow icon