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.
Unfortunately, activation email could not send to your email. Please try again.

'Id' Property on DropDownListFor Control

Thread ID:

Created:

Updated:

Platform:

Replies:

129413 Mar 16,2017 06:48 AM Mar 17,2017 01:51 AM ASP.NET Core 2
loading
Tags: DropDownList
Sean McGurk
Asked On March 16, 2017 06:48 AM

 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

Sean McGurk
Replied On March 16, 2017 07:03 AM

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();
                            }

Gopi Govindasamy [Syncfusion]
Replied On March 17, 2017 01:51 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;