This is a migrated thread and some comments may be shown as answers.

TagHelper and HtmlHelper generate different Id

1 Answer 144 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Bilgi Islem
Top achievements
Rank 1
Bilgi Islem asked on 26 Jun 2020, 11:10 AM

hello,

i used ddl with taghelper

  <kendo-dropdownlist for="EmlakBinaBeyan.YeniBinaIndirimiUygulandiMi"
                                                                        bind-to="Html.GetEnumSelectList(typeof(EvetHayirEnum))"
                                                                        readonly="readonly"
                                                                        class="form-control form-control-sm"
                                                                        style="width:100%">

  </kendo-dropdownlist>

this generate ID with comma.

<input data-val="true" data-val-required="The KisitlilikVarMi field is required." id="EmlakBinaBeyan.KisitlilikVarMi" name="EmlakBinaBeyan.KisitlilikVarMi" type="text" value="0" data-role="dropdownlist" style="display: none;">

 

but i used ddl with html helper, also same code

                                                    @(Html.Kendo().TextBoxFor(x => x.EmlakBinaBeyan.ArsaNetM2).HtmlAttributes(new { @class = "form-control form-control-sm text-lg-left text-muted", @readonly = "readonly" }))

this generate ID with underline

<input type="text" data-val="true" data-val-required="The KisitlilikVarMi field is required." id="EmlakBinaBeyan_KisitlilikVarMi" name="EmlakBinaBeyan.KisitlilikVarMi" value="Hayir" data-role="dropdownlist" style="display: none;">

 

so, same code tag helper and html helper generate different Id. I want take value with jquery selector, i cant take value with taghelper, but i can take value with html helper .

var dropdownlist22 = $("#EmlakBinaBeyan_KisitlilikVarMi").data("kendoDropDownList");

 

why generated different Id ?

 

Best Regards.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Veselin Tsvetanov
Telerik team
answered on 30 Jun 2020, 05:09 AM

Hello Bilgi Islem,

Generating an ID with a dot inside for the DropDownList <input> element is not correct. That is why we should fix the Tag helper implementation so that it generates properly the <input> ID with a lower dash in it.

Here you could find the GitHub issue that I have opened on the above:

https://github.com/telerik/kendo-ui-core/issues/5883

As per the proper way to get a reference to an element with a dot in its ID with jQuery, I would suggest you review the following StackOverflow thread:

https://stackoverflow.com/questions/9930577/jquery-dot-in-id-selector/9930611

As a small token of gratitude for reporting the above, I have updated your Telerik points.

Regards,
Veselin Tsvetanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
DropDownList
Asked by
Bilgi Islem
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or