Change defautl "id" in Kentio Biz Froms

Dcode warner asked on March 9, 2017 18:27

Is there no way to change the default ID for input fields on Kentico for each field? Change this: "p_lt_ctl05_pageplaceholder_p_lt_ctl02_content_widget1_ctl00_viewBiz_ctl00_fl_jupiter_list_0" to "hotelID"

Example: </ input id="p_lt_ctl05_pageplaceholder_p_lt_ctl02_content_widget1_ctl00_viewBiz_ctl00_fl_jupiter_list_0" name="hotels" checked="checked" value="2HHZ8" class="hotel-list-checkbox" type="checkbox" />

Correct Answer

Brenden Kehren answered on March 9, 2017 18:55

There isn't but Kentico does assign an ID to an outer container in the markup using the field name. See below. If you need to access it via JS then use the outer container ID. If you don't render the table, then there will be a <div> tag with the ID set based on the field name.

Image Text

0 votesVote for this answer Unmark Correct answer

Recent Answers


Trevor Fayas answered on March 9, 2017 18:39

The ID is a full path to the control and needed for postbacking.

However if you're trying to get at a certain field in Javascript so you can select it, use the jQuery selector like this:

$("input[id*='jupider_list']")

Or

$("input[name='hotels']")

the *= means contains, ^= is Starts with, i think $= is ends with, and = is equals.

Same can be done with CSS to apply styling.

1 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on March 9, 2017 21:56 (last edited on March 9, 2017 22:18)

There are different workarounds, I personally do it with jQuery etc, but yes you can: so instead of id="p_lt_ctl00_BizForm2_viewBiz_email_txtEmailInput" you get id="txtEmailInput" I suggest you clone existing bizform web part (\CMSWebParts\Bizforms\Bizform). The only change you need to make is in bizform.ascx

<cms:BizForm ID="viewBiz" runat="server" IsLiveSite="true" /> change to <cms:BizForm ID="viewBiz" runat="server" IsLiveSite="true" ClientIDMode="Static" />

But there is a limitation: I don't know if this is fixed in 9 or 10, but in 8 the problem with this is: if you have 2 text boxes, lets say username and fullname they both get id="txtText" Normally they would been called p_lt_ctl00_BizForm2_viewBiz_username_txtText and p_lt_ctl00_BizForm2_viewBiz_fullname_txtText. I guess if they reverse control type and control name we can fully use clientIDMode.

P.S. Perhaps, we can open a ticket or suggest a new feature, but I am fine with jQuery solution.

0 votesVote for this answer Mark as a Correct answer

Zach Perry answered on March 9, 2017 22:21

What do you need the ID changed for? You could add a class to the field, in the fields for the biz from, you can add a class to the Control CSS Class and use that isntead.

You will end up with something like class="form-control CustomClassName"

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.