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

'Id' Property on DropDownListFor Control

 Hi,

is it possible for a control to have both an 'id' property and a 'for' property

I have created the following drop-down list control:

@{Html.EJ().DropDownListFor(b => b.BarrelNumber)
                                .Datasource((IEnumerable<Barrel>)ViewBag.Barrels)
                                .DropDownListFields(Df => Df.Text("BarrelNumberNavigation.Number")
                                .Value("BarrelNumber"))
                                .Render();
                            }

and I want to give the drop down list an 'id' property (so that I can cascade to it from another drop-down list).

Is this possible? If so, how would I go about it?

Thanks,

Sean

2 Replies

SM Sean McGurk March 16, 2017 11:03 AM UTC

Or... alternatively, how I would include a 'for' property on this control:

 @{Html.EJ().DropDownList("Barrels")   
                                .Datasource((IEnumerable<Barrel>)ViewBag.BarrelAssignments)
                                .DropDownListFields(Df => Df.Text("BarrelNumberNavigation.Number")
                                .Value("BarrelIdentifierId"))
                                .Render();
                            }


GG Gopi Govindasamy Syncfusion Team March 17, 2017 05:51 AM UTC

Hi Sean McGurk,  

Is not possible to use both 'id' and 'for' property. In dropdownlistfor control will generate id and this id used to cascade to another dropdownlist. We have prepared a sample based on your requirement by using cascade to dropdownlistfor. We have attached sample below link.  

   @Html.EJ().DropDownList("groupsList").Datasource((IEnumerable<groups>)ViewBag.datasource).DropDownListFields(f => f.Value("parentId").Text("text")).CascadeTo("auto1").ClientSideEvents(e => e.Change("onChange")).WatermarkText("Select") 
    </div> 
    <div class="col-xs-8 col-sm-4"> 
        <span class="txt">Select Country</span> 
        @Html.EJ().DropDownListFor(model => model.auto1, (Syncfusion.JavaScript.Models.DropDownListProperties)ViewData["ddl"]).Enabled(false) 
    </div> 

 
Regards, 
Gopi G. 


Loader.
Up arrow icon