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

Why is not the dropdownlist rendered in a partialview?

|I'm trying to create a form with a dropdownlist in a partial view, but when I run my application, only one textbox appears. I did tests with a grid, with a button and with a dialog and there is no problem.
here is my code
@(
                    Html.EJS().DropDownList("Album")
                    .DataSource(dataManager => dataManager.Url(Url.Action("Albums", "JS2", null, Request.Url.Scheme)).Adaptor("UrlAdaptor").CrossDomain(true))
                    .Placeholder("Selecciona")
                    .PopupHeight("200px")
                    .Fields(new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings
                    {
                        Value = "AlbumId",
                        Text = "Titulo"/*, Id="AlbumId"*/
                    })
                    .ActionComplete("complete").ActionFailure("fail").Change("onSelect")
                    .Render()
    )

public ActionResult GetArtista(Syncfusion.EJ2.Base.DataManagerRequest dm)
        {
            var data = read.GetArtistas();

            return Json(data);
        }

I have another question: Can @Ajax.BeginForm be used with Syncfusion controls?
I hope you can help me. I thank you very much

3 Replies

PO Prince Oliver Syncfusion Team March 8, 2019 11:58 AM UTC

Hi Juan, 

Thank you for contacting Syncfusion support. 

Query 1: I'm trying to create a form with a dropdownlist in a partial view, but when I run my application, only one textbox appears. 

We have checked your scenario and shared code snippet. We suspect that you might have missed to bind events to the DropDownList component but have initialized your script. This could have caused script error in the application and the control is not rendered. Kindly ensure whether all the events have their respective JavaScript handler functions. 

@( 
    Html.EJS().DropDownList("Album") 
    .DataSource(dataManager => dataManager.Url(Url.Action("Albums", "JS2", null, Request.Url.Scheme)).Adaptor("UrlAdaptor").CrossDomain(true)) 
    .Placeholder("Selecciona") 
    .PopupHeight("200px") 
    .Fields(new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings 
    { 
        Value = "AlbumId", 
        Text = "Titulo"/*, Id="AlbumId"*/ 
    }) 
    .ActionComplete("complete").ActionFailure("fail").Change("onSelect") 
    .Render() 
) 
 

 Also, please add “@Html.EJS().ScriptManager()”  at the end of the partial view page. We have prepared sample based on your scenario. Kindly refer to the following code snippet. 

[main page] 
<div class="col-lg-12 control-section" style="margin: 50px"> 
    <div id="wrapper"> 
    </div> 
</div> 
<button id="datebutton" text="Click" onclick="onClick()"> click Partial view </button> 
<script type="text/javascript"> 
    function onClick() { 
        var ajax = new ej.base.Ajax('/Home/PartialView1/?Person2', 'GET', true); 
        ajax.send().then(); 
        ajax.onSuccess = function (data) { 
            $("#wrapper").html(data); 
        } 
    } 
</script> 
 

[partial view page] 
<div id="Myfrom" style="width:300px"> 
 
@(Html.EJS().DropDownList("Album").DataSource((IEnumerable<object>)ViewBag.data) 
 
    .Placeholder("Selecciona").PopupHeight("200px").Render() 
 
) 
 
@Html.EJS().ScriptManager() 
 

We have attached a sample for your reference, please find the sample at the following location. 

Query 2: Can @Ajax.BeginForm be used with Syncfusion controls? 

Yes, you can use Ajax.BeginForm with Syncfusion controls. 

Please let us know if you need any further assistance on this. 

Regards, 
Prince 



JC Juan Cruz March 8, 2019 09:21 PM UTC

I appreciate that you have answered my two questions. I would like to know if you can put Syncfusion controls (like dropdownlist, datepicker, etc) into a dialog control to create a form


PO Prince Oliver Syncfusion Team March 11, 2019 08:53 AM UTC

Hi Juan, 
 
Thank you for your update. 
 
Yes, you can put Syncfusion controls (like dropdownlist, datepicker, etc) into a dialog control to create a form. We have prepared simple sample for Dialog component with partial page content. We have covered below things on the sample. 
 
  • We have rendered Dialog component and hide on initial rendering using visible property.
  • We have got partial view page content using ajax post and append into Dialog content element before open the dialog component using BeforeOpen event.
 
 
Kindly refer to the following links for further reference. 
 
Online Demo sample for loading AJAX content: https://ej2.syncfusion.com/aspnetmvc/Dialog/AjaxContent#/material  
 
Please let us know if you need any further assistance on this.  
 
Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon